Using the split-apply-combine strategy with plyr

Many data analysis tasks involve first splitting the data into subsets, applying some operation on each subset, and then combining the results suitably. A common wrinkle in applying this happens to be the numerous possible combinations of input and output object types. The plyr package provides simple functions to apply this pattern while simplifying the specification of the object types through systematic naming of the functions.

A plyr function name has three parts:

  • The first letter represents the input object type
  • The second letter represents the output object type
  • The third to fifth letters are always ply

In the plyr function names, d represents a data frame, l represents a list, and a represents ...

Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.