End of Summer - hours only!Up to 80% off on all courses and bundles.-Close
The lapply() function
Other apply() functions
12. sapply(), lapply(), and inputs that are not lists
The split-apply-combine pattern


Remember: both sapply() and lapply() can take other objects as arguments; they'll simply use the as.list() function in that case.

After this conversion, lapply()/sapply() work as usual – they take this converted object (list) and perform the calculations (applying the given function to each list member).


Use sapply() to display the quantiles of the number of pieces sold for each day. This time, instead of the sales list, use the data frame object named sales_df.

Notice how using a data frame instead of a list doesn't change anything. The only difference here is that R uses as.list() and converts the data frame to a list before the quantile() function is invoked.

Stuck? Here's a hint!


sapply(sales_df, quantile)