Skip to content
Back to formatted view

Raw Message

Message-ID: <1354308574554-4651494.post@n4.nabble.com>
Date: 2012-11-30T20:49:34Z
From: threshold
Subject: subgroup-based quantiles
In-Reply-To: <50B9048B.2010806@sapo.pt>

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.