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

Instruction

Great! You're done with the splitting phase of split-apply-combine. Now you have a list where each member represents one year's worth of data.

You can easily apply an aggregate function to each list member. Luckily, we know how to do that! You can use lapply() or sapply() to get the total number of bracelets sold in each year by applying the sum function to each list member.

Exercise

Use lapply() on the list named pieces_sold_per_year to calculate the total number of bracelets sold in each year. Assign the result to a variable named sum_of_pieces.