Created
January 6, 2017 04:59
-
-
Save Keiku/2a117decef4b2000ac1d2dbe2aafd84b to your computer and use it in GitHub Desktop.
Calculate percentiles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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