Created
February 12, 2016 15:54
-
-
Save gshotwell/89c02a7b06870b64b5a6 to your computer and use it in GitHub Desktop.
Bind Cols vs. reduce(list, c)
This file contains 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(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