I have a dataframe with multiple variables and I would like to find the quantiles () of each of these variables
Sample code:
testtable = data.frame(groupvar = c(rep('x',100), rep('y',100)),
numericvar = rnorm(200))
I want to apply quantile(., c(.05, .1, .25, .5, .75, .9, .95)
) to each of the variables in testtable
. The ideal result would look like
x y
.05 .05
.1 .1
.25 .25
.5 .5
.75 .75
.9 .9
.95 .95
where each entry is a quantile of x
or y
. For sample, .05
is the 5th percentile of the x
.1
is the 10th percentile distribution of x
, etc.
I tried summarise
in dplyr
but ran into a problem because my quantile
function is returning a vector of length 7.
What is the best way to do this?