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

## Instruction

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

## Exercise

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.