oops. If x1 is the individual try
x2.mean<-aggregate(data[2:2], list(x1), mean) x2.mean you can change "mean" by any function. cheers milton On Mon, Jun 8, 2009 at 8:20 AM, milton ruser <milton.ru...@gmail.com> wrote: > Hi Amor, > I think you forgot to include the individual ID. > ?aggregate > > cheers > milton > brazil=toronto > > On Mon, Jun 8, 2009 at 8:11 AM, amor Gandhi <amorigan...@yahoo.de>wrote: > >> Hi, >> >> I have gote the following data >> >> x1 <- c(rep(1,6),rep(4,7),rep(6,10)) >> x2 <- rnorm(length(x1),6,1) >> data <- data.frame(x1,x2) >> >> and I would like to compute the mean of the x2 for each individual of x1, >> i. e. x1=1,4 and 6? >> >> Thank you very much in advance, >> >> Amori >> >> >> >> [[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<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.