Created
May 31, 2016 17:47
-
-
Save hadley/3800fe443d53ba9f67c11145b56190d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(data.table) | |
dt <- data.table(x = 1:10) | |
bad_fun <- function(x) { | |
if (x > 5) | |
stop("Uhoh") | |
x * 10L | |
} | |
dt[, x := bad_fun(x), by = x] | |
dt | |
slow_fun <- function(x) { | |
Sys.sleep(10) | |
x * 10L | |
} | |
dt[, x := slow_fun(x), by = x] | |
dt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment