Create a table of Quantiles in R for multiple Subsets of Data
Posted
by
user1489719
on Stack Overflow
See other posts from Stack Overflow
or by user1489719
Published on 2012-07-06T21:12:32Z
Indexed on
2012/07/06
21:15 UTC
Read the original article
Hit count: 145
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?
© Stack Overflow or respective owner