[R] basic question

From: jose silva <chess.player_at_oninet.pt>
Date: Fri 22 Apr 2005 - 01:31:01 EST


I know this question is very simple, but I am not figure it out  

I have the data frame:  

 
 

test<- data.frame(year=c(2000,2000,2001,2001),x=c(54,41,90,15), y=c(29,2,92,22), z=c(26,68,46,51))  

test  

  year    x   y   z
 

1 2000 54 29 26  

2 2000 41  2  68  

3 2001 90 92 46  

4 2001 15 22 51  

 
 

I want to sum the vectors x, y and z within each year (2000 and 2001) to obtain this:  

 
 

year       x   y    z  

1 2000  95  31 94  

2 2001 105 114 97  

 
 

I tried tapply but did not work (or probably I do it wrong)  

 
 

Any suggestions?   

 
 

silva

        [[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 Received on Fri Apr 22 01:33:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:21 EST