O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the split-apply-combine strategy with plyr

A common analytical pattern is to split data into pieces, apply some function to each piece, and then combine the results back together. The plyr package provides simple functions to apply this pattern, while simplifying the specification of the object types through systematic naming of the functions.

The plyr function name has three parts, XYply, where X specifies what sort of input you're giving , Y specifies the sort of output you want and ply part is common to all function names. X and Y represent one of the following options:

  • a = array
  • d = data.frame
  • l = list
  • _ = no output; only valid for Y; for example, useful when you're operating on a list purely for the side effects, making a plot, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required