Rainbow Deals - hours only!Up to 80% off on all courses and bundles.-Close
The lapply() function
Other apply() functions
The split-apply-combine pattern
15. The split-apply-combine pattern


Perfect! That's it. tapply() actually represents the split-apply-combine pattern of working with data in R. What does this mean? Quite often in data analysis, we need to break our main data set into subsets and perform calculations on each of those groups. Once we've performed those calculations, we merge the subgroups into one final data set.

When you think about it, tapply() does exactly that—it takes an object representing your data, splits that into smaller pieces (subgroups), applies a given function to perform certain calculations, and returns a single result.


Click Next exercise to continue.