Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate percentiles.
library(dplyr)
library(broom)
mtcars %>%
group_by(cyl) %>%
do(tidy(t(quantile(.$mpg, probs = seq(0, 1, 0.25)))))
# Source: local data frame [3 x 6]
# Groups: cyl [3]
#
# cyl X0. X25. X50. X75. X100.
# <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
# 1 4 21.4 22.80 26.0 30.40 33.9
# 2 6 17.8 18.65 19.7 21.00 21.4
# 3 8 10.4 14.40 15.2 16.25 19.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.