Why use plyr?

December 17, 2009
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

The "apply" family of functions in R (apply, sapply, lapply) is a very powerful suite of tools for iterating through structures of data and returning the combined results of each iteration. But with great power comes great responsibility (or something like that): these functions can sometimes be frustratingly difficult to get working exactly as you intended, especially for newcomers to R.

That's where the functions from Hadley Wickham's plyr package come in: they create a unified interface for iterating over data in R with a consistent syntax for specifying what the inputs are, and what the outputs should be. 

JD Long captures both the frustration that come with mis-applying apply and the joy of overcoming it with plyr in this 5-minute video. Be sure to check the associated blog post for the background and comments.



 Cerebral Mastication: Struggling with apply() in R

To leave a comment for the author, please follow the link and comment on his blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.