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.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to