I have dataframe with a column "rt" that I would like to know what percentile each row falls under.
for example
set.seed ( 1)
df <- data.frame(rt = rnorm(60), id = rep(letters[1:3], rep(20)) )
> head ( df)
rt id
1 -0.6264538 a
2 0.1836433 b
3 -0.8356286 c
4 1.5952808 a
5 0.3295078 b
6 -0.8204684 c
so the way I do it now is to loop through each quantile and assign the precentile for that number. For example
q = quantile(df$rt, seq(0, 1, .01) )
df[df$rt >= q[96], ]
rt id
4 1.595281 a
11 1.511781 b
56 1.980400 b
I now know that these samples are in the top 96% and would just go through each row, however is there a way to do this for all numbers without manually going through each percentile?
thanks!