[R] subgroup-based quantiles

R Kozarski r.kozarski at gmail.com
Fri Nov 30 21:49:34 CET 2012


Dear Arun and Rui,  thank you for replying, your commands are very helpful.
Before you replied, Ive solved the issue with the following approach (for
quartiles):

myFun <- function(x, GENDER)
{
    x.male <- cut(x, labels=c(1:4), breaks=quantile(split(x,GENDER) $ '1',
seq(0,1,.25), na.rm=TRUE),include.lowest = TRUE)
    x.female <- cut(x, labels=c(1:4), breaks=quantile(split(x,GENDER) $ '2',
seq(0,1,.25), na.rm=TRUE),include.lowest = TRUE)
    ifelse(GENDER==1, x.male, x.female)
}


Robert




--
View this message in context: http://r.789695.n4.nabble.com/subgroup-based-quantiles-tp4651415p4651494.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list