[R] mean
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Mon Jun 8 14:15:56 CEST 2009
have a look at ?tapply(), e.g.,
x1 <- c(rep(1,6),rep(4,7),rep(6,10))
x2 <- rnorm(length(x1),6,1)
tapply(x1, x1, mean)
I hope it helps.
Best,
Dimitris
amor Gandhi 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 at 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.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
More information about the R-help
mailing list