Skip to content

Instantly share code, notes, and snippets.

@gshotwell
Created February 12, 2016 15:54
Show Gist options
  • Save gshotwell/89c02a7b06870b64b5a6 to your computer and use it in GitHub Desktop.
Save gshotwell/89c02a7b06870b64b5a6 to your computer and use it in GitHub Desktop.
Bind Cols vs. reduce(list, c)
library(purrr)
library(dplyr)
library(microbenchmark)
list <- map(1:1000, function(x) rep("a", 100))
f1 <- function(list){
reduce(list, c)
}
f2 <- function(list){
map(list, function(x) data_frame(char = x)) %>%
bind_rows() %>%
.$char
}
microbenchmark(f1(list), f2(list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment