Create a table of Quantiles in R for multiple Subsets of Data
- by user1489719
I'm trying to create append a table of quantiles in R for multiple subsets of data.
Right now, I have a vector of ids (p_ids) in table DATA, which are not consecutive. For each value in p_ids, I am looking to list the quantile.
So far, I've tried variations of:
i <- 1
n <- 1
for (i in p_ids) {
while(n <= nrow(data)) {
quantiles[n] <- quantile(subset(alldata$variableA, alldata$variableB == i),probs = c(0,1,2,3)/3)
n <- n + 1
}
}
I know my issue lies somewhere in the index, but I can't seem to get where the index should go. Suggestions?