[R] Averaging over columns
Jacques VESLOT
jacques.veslot at cirad.fr
Mon Mar 6 13:30:34 CET 2006
t(as.matrix(aggregate(t(as.matrix(DF)), rep(1:12,each=3), mean)[,-1]))
michael watson (IAH-C) a écrit :
>Hi
>
>I've been reading the help for by and aggregate but can't get my head
>round how to do this.
>
>I have a data frame - the first three columns are replicate
>measurements, then the next 3 are replicates etc up to 36 (so 12
>variables with 3 replicate measurements each). I want to compute the
>mean for each of the 12 variables, so that, for each row, I have 12
>means.
>
>A grouping variable across columns can easily be created by
>rep(1:12,each=3), but I can't figure out which function to use to get R
>to calculate the means I want.
>
>Thanks in advance
>Mick
>
>______________________________________________
>R-help at 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
>
>
>
More information about the R-help
mailing list