We will utilize the dplyr verbs to create complex data summary tables. In order to do so, the following steps need to be executed:
- Load the diamonds dataset using the following code:
data(diamonds)
- Group the data by cut, color, and clarity, and find the number of observations at each combination of the three variables, as follows:
diamonds %>% group_by(cut, color, clarity) %>% summarise(n())
- Find the mean and median price of diamonds by using the dplyr functions group_by() and summarise() as follows:
diamonds %>% group_by(cut) %>% summarise(mean = mean(price), median = median(price))
- We can also filter out data we're not interested in quickly using dplyr methods. Say we don't want ...