Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
The lapply() function
Other apply() functions
14. tapply() – practice
The split-apply-combine pattern


Great! Let's practice tapply() with another example.


Smartcom has information about sales that were made in 2016 and 2017 in a data frame named sales_per_month. For each year, we have the number of bracelets sold (sold_pieces) for each of the 12 months within that year. Calculate the total sales for each year.

Stuck? Here's a hint!

Use tapply(). The first argument is sales_per_month$sold_pieces; the second one is sales_per_month$year. The third argument should be sum.