Skip to content

Instantly share code, notes, and snippets.

@ThoDuyNguyen
Created October 15, 2016 18:02
Show Gist options
  • Save ThoDuyNguyen/f44c958cb6ba69e9d1c6703ae5743029 to your computer and use it in GitHub Desktop.
Save ThoDuyNguyen/f44c958cb6ba69e9d1c6703ae5743029 to your computer and use it in GitHub Desktop.
library(purrr)
library(dplyr)
dump_data_frame <- function(i) {
return(data.frame(
a = rep.int(i, i * 1000000),
b = rep.int(i * 2, i * 1000000),
c = rep.int(i * 3, i * 1000000),
d = rep.int(i * 4, i * 1000000)
))
}
list_data_frame <- map(c(1,2,3,4,5), dump_data_frame)
ptm <- proc.time()
last_data_frame <- reduce(list_data_frame, function(x, y) {
return(bind_rows(x, y))
})
proc.time() - ptm
ptm <- proc.time()
last_data_frame <- reduce(list_data_frame, function(x, y) {
return(rbind(x, y))
})
proc.time() - ptm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment