Hi Marianne, Please consider the following:
with(table, aggregate(rt, list(group, session), FUN = median)) HTH, Jorge On Wed, Dec 8, 2010 at 9:29 AM, Marianne Stephan <> wrote: > > Hello everybody, > I would like to calculate the median for each factor combination, with only > one value per factor combination as an output. > Could anybody help me? > > > For example: > # make table > g<-1:2 > group<-rep(g, each=5) > session<-c(1,1,2,2,2,1,1,1,2,2) > rt<-seq(length=10,300, 800) > rt<-round(rt, digits=2) > table<-data.frame(group, session, rt) > table > > group session rt > 1 1 1 300.00 > 2 1 1 355.56 > 3 1 2 411.11 > 4 1 2 466.67 > 5 1 2 522.22 > 6 2 1 577.78 > 7 2 1 633.33 > 8 2 1 688.89 > 9 2 2 744.44 > 10 2 2 800.00 > > > > > Besides others I tried the following: > median<-ave(rt, group, session, FUN=median) > median<-frameApply(table,by=c("group", "session"), on="rt", fun=median) > > I would appreciate your help a lot. > Marianne > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.