Relative frequencies / proportions with dplyr
Suppose I want to calculate the proportion of different values within each group. For example, using the mtcars data, how do I calculate the relative frequency of number of gears by am (automatic/manual) in one go with dplyr? library(dplyr) data(mtcars) mtcars <- tbl_df(mtcars) # count frequency mtcars %>% group_by(am, gear) %>% summarise(n = n()) # … Read more