We released the package quickpsy a few years ago (paper in the R journal paper). The package used R base functions, but also made an extensive use of functions of what was called at that time the Hadleyverse. We are now developing a new version of the package that mostly uses functions from the tidyverse and that incorporates the new non-standard evaluation approach and found that the package is much much slower (more than four times slower). We found for example that purrr::map is much slower than dplyr::do (which is deprecated):
library(tidyverse)
system.time(
mtcars %>%
group_by(cyl) %>%
do(head(., 2))
)
system.time(
mtcars %>%
group_by(cyl) %>%
nest() %>%
mutate(temp = map(data, ~head(., 2))) %>%
unnest(temp)
)
We also found that functions like pull are very slow.
We are not sure whether the tidyverse is not meant to be used for this type of programming or we are not using it properly.
data.tableis going to be your friend. - sindri_balduras.data.table(mtcars)[, .SD[1:2], by = cyl]- sindri_baldurdata.tableyou can:data.table(mtcars)[, .SD[1:2], cyl]- pogibasmap()that is slow, but nest and unnest. Perhaps because of selection? Tidyselect is written in pure R. Yourmtcarsbenchmark does not demonstrate that the functions are slow though, just that they are slower. If the slowness increases with data frame size, then there might be a problem. - Lionel Henry