Split, Apply, Combine: Using Base R (Introduction to Statistical Computing)

October 8, 2012
By

(This article was originally published at Three-Toed Sloth , and syndicated at StatsBlogs.)

Lecture 11: Design patterns and their benefits: clarity on what is to be done, flexibility about how to do it, ease of adapting others' solutions. The split/apply/combine pattern: divide big structured data sets up into smaller, related parts; apply the same analysis to each part independently; combine the results of the analyses. Trivial example: row and column means. Further examples. Iteration as a verbose, painful and clumsy implementation of split/apply/combine. Tools for split/apply/combine in basic R: the apply function for arrays, lapply for lists, mapply, etc.; split. Detailed example with a complicated data set: the relation between strikes and parliamentary politics.

Introduction to Statistical Computing



Please comment on the article here: Three-Toed Sloth

Subscribe

Email:

  Subscribe