Skip to content

Instantly share code, notes, and snippets.

@hadley
Created May 31, 2016 17:47
Show Gist options
  • Save hadley/3800fe443d53ba9f67c11145b56190d2 to your computer and use it in GitHub Desktop.
Save hadley/3800fe443d53ba9f67c11145b56190d2 to your computer and use it in GitHub Desktop.
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