It may be kind of surprising that you can pass a function as an argument to another function, so let's verify first that it worked. We've found the column means and medians using our old col_mean() and col_median() functions. Your job is to repeat the calculations using col_summary() instead and verify that it works.

Not only does col_summary() remove the duplication in the functions we've already written, it also allows us to apply any summary to the columns of a data frame. Verify this, by finding the column interquartile ranges using the function IQR(). (For more info, see ?IQR.)

Instructions

100 XP

Find the column medians of df by specifying median as the fun argument to col_summary().

Find the column means of df by specifying mean as the fun argument to col_summary().