Last active
December 19, 2018 12:00
-
-
Save JoFAM/35286bb8a144e6c2c0ada106eb818c4e to your computer and use it in GitHub Desktop.
lift_dl() versus rbind()
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
``` r | |
library(magrittr) | |
library(purrr) | |
#> | |
#> Attaching package: 'purrr' | |
#> The following object is masked from 'package:magrittr': | |
#> | |
#> set_names | |
library(microbenchmark) | |
library(reprex) | |
microbenchmark( | |
1:10 %>% | |
map(~list(a = ., b = .)) %>% | |
transpose() %>% | |
map(unlist) %>% | |
lift_dl(data.frame)(), | |
1:10 %>% | |
map(~list(a = ., b = .)) %>% | |
do.call(what = rbind, args = .) | |
) | |
#> Unit: microseconds | |
#> expr | |
#> 1:10 %>% map(~list(a = ., b = .)) %>% transpose() %>% map(unlist) %>% lift_dl(data.frame)() | |
#> 1:10 %>% map(~list(a = ., b = .)) %>% do.call(what = rbind, args = .) | |
#> min lq mean median uq max neval cld | |
#> 537.991 616.6795 765.5846 705.418 765.075 3498.220 100 b | |
#> 248.896 280.1150 345.6871 332.289 351.319 1193.586 100 a | |
``` | |
<sup>Created on 2018-12-19 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)</sup> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment