Cheatsheet for moving from `plyr` to `purrr`



I am trying to move my scripts from plyr to purrr, but have had trouble in finding the analogous functions between the two. My main motivation is the minimize the amount of imports i have for my packages.

My main question is there a reference sheet that maps common plyr commands to purrr commands? the only place i found so far was a one off showing the purrr alternative for plyr::ldply in a file.

A common call in plyr is plyr::ddply, is there a purrr solution for that (since a dataframe is a very specific list type)?



this post by @jennybryan answered my question. thanks @mara for pointing it out to me.


To duplicate the functionality in plyr, you will likely need to look in (at least) dplyr in addition to purrr. There’s isn’t necessarily a one-to-one relationship between functions, however. In a broad sense, plyr focuses on the shape of your input versus the shape of your output, while the tidyverse (and dplyr in particular) often works best with data frames/tibbles as both the input and output.

That means that the exact functions needed to replace ddply depends on what you are trying to do with it. The one commonality is that you would typically use dplyr::group_by to first group the data. After that, you might use dplyr::summarize to create a new data frame with each unique combination of your grouped columns along with one or more new columns calculated with one row per group. Alternatively, you might use dplyr::mutate to add a column that uses a per-group calculation, such as dividing one column by the per-group minimum from that column.


@jimhester’s blog post is even more focused on plyr to dplyr translation. It was written a while ago, so a few things aren’t current (e.g., do() and qplot()), but it holds up very well.


I have your (Jenny’s), @rajkorde, Karl Broman, and @jimhester’s respective base :recycle: tidyverse conversion posts in here, but if there are any other :+1: ones you ran into, @yonicd, or anyone, lmk.

Not exhaustive by any means, and it’s not really tidyverse on the whole…that’s clarity suffering at the hands of paronomasia :grimacing:!