I have some data that looks like the following. It is grouped by variable \"Year\" and I want to extract the percentiles of each observation of Score, with respect to t
Using data.table is pretty straight-forward as well. Just for completeness and also as an easy way to find the data.table solution.
library(data.table) year <- rep(2001:2005, 2) score <- round(rnorm(10, 35, 3)) dt <- data.table(score) dt[, .(Percentile = ecdf(score)(score)), by = list(year)]