[R] new R-user needs help

Stefano Calza stecalza at tiscali.it
Wed Oct 18 11:27:45 CEST 2006


Hi,

you can use aggregate.

aggregate(data[,c(3:8)],list(data$name),mean)

should give you what you want.

Ciao,
Stefano


On Wed, Oct 18, 2006 at 11:10:04AM +0200, antoniababe at yahoo.se wrote:
<antoniababe>Dear all,
<antoniababe>
<antoniababe>I have a dataset 
<antoniababe>
<antoniababe>Exp name id x1 x2 x3 x4 x5 
<antoniababe>1   a    1  23 24 23 22 30
<antoniababe>1   b    2  25 26 27 23 24
<antoniababe>1   c    3  32 19 23 25 28
<antoniababe>2   a    4  28 32 24 26 27
<antoniababe>2   b    5  23 24 25 26 28
<antoniababe>2   c    6  23 31 30 38 23
<antoniababe>3   a    7  24 25 31 27 29
<antoniababe>3   b    8  28 25 26 32 28 
<antoniababe>3   c    9  21 31 28 23 29
<antoniababe>
<antoniababe>where each name a,b and c is repeated three times.
<antoniababe>Now I want to calculate the the averages of a,b and c
<antoniababe>over the three experiments for each x. For example for
<antoniababe>x1 I want to calculate the average of a like
<antoniababe>
<antoniababe>[a(from exp1) + a(exp2)+ a(exp3)]/3= (23+28+24)/3
<antoniababe>
<antoniababe>How can I do that ?
<antoniababe>
<antoniababe>Thanks for your help,
<antoniababe>Regards,
<antoniababe>
<antoniababe>Antonia
<antoniababe>
<antoniababe>______________________________________________
<antoniababe>R-help at stat.math.ethz.ch mailing list
<antoniababe>https://stat.ethz.ch/mailman/listinfo/r-help
<antoniababe>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
<antoniababe>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list