title: Programming using the tidyverse: speed issues
body: <p>We released the package <a href="https://cran.r-project.org/web/packages/quickpsy/index.html" rel="nofollow noreferrer">quickpsy</a> a few years ago (<a href="https://journal.r-project.org/archive/2016-1/linares-na.pdf" rel="nofollow noreferrer">paper in the R journal paper</a>). 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 <a href="https://github.com/danilinares/quickpsy/tree/testingSpeed" rel="nofollow noreferrer">new version</a> of the package that mostly uses functions from the tidyverse and that incorporates <a href="https://dplyr.tidyverse.org/articles/programming.html" rel="nofollow noreferrer">the new non-standard evaluation approach</a> 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):</p>
  
  <pre><code>library(tidyverse)
  
  system.time(
    mtcars %&gt;% 
      group_by(cyl) %&gt;% 
      do(head(., 2))
    )
  
  system.time(
    mtcars %&gt;% 
      group_by(cyl) %&gt;% 
      nest() %&gt;% 
      mutate(temp = map(data, ~head(., 2))) %&gt;% 
      unnest(temp)
  )
  </code></pre>
  
  <p>We also found that functions like <code>pull</code> are very slow. </p>
  
  <p>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.  </p>