Hi R-users, I have a data.frame like this (modificated from https://stat.ethz.ch/pipermail/r-help/2007-August/138124.html).
y1 <- rnorm(20) + 6.8 y2 <- rnorm(20) + (1:20*1.7 + 1) y3 <- rnorm(20) + (1:20*6.7 + 3.7) y <- c(y1,y2,y3) x <- rep(1:5,12) f <- gl(3,20, labels=paste("lev", 1:3, sep="")) d <- data.frame(x=x,y=y, f=f) and this is how I can calculate mean of these levels. tapply(d$y, list(d$x, d$f), mean) But how can I calculate the mean of d$x 1 and 2 and the grand mean of d$x 1, 2, 3, 4, 5 (within d$f) into a table? Regards, Lauri [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.