Re: [R] Summing by index

2010-07-30 Thread steven mosher
very slick Thx. On Fri, Jul 30, 2010 at 12:44 PM, Wu Gong wrote: > > Hi, > > R has a buildin function ?rowsum > > rowsum(DF$Data,DF$Id,na.rm=T) > > - > A R learner. > -- > View this message in context: > http://r.789695.n4.nabble.com/Summing-by-index-tp2308332p2308411.html > Sent from the R

Re: [R] Summing by index

2010-07-30 Thread Wu Gong
Hi, R has a buildin function ?rowsum rowsum(DF$Data,DF$Id,na.rm=T) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Summing-by-index-tp2308332p2308411.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Summing by index

2010-07-30 Thread steven mosher
Thanks again david. To finish out the example. DF Id Year Data 1 1234 1990 14 2 1234 1991 15 3 1234 1992 16 4 1234 1993 17 5 1234 1994 18 6 5436 1991 NA 7 5436 1992 20 8 5436 1993 21 9 7864 1990 22 10 7864 1991 23 11 7864 1992 24 12 7864 1993 25 result<-by(D

Re: [R] Summing by index

2010-07-30 Thread steven mosher
ha. that was a stupid mistake. Thanks. On Fri, Jul 30, 2010 at 11:46 AM, David Winsemius wrote: > > On Jul 30, 2010, at 2:41 PM, steven mosher wrote: > > # build a sample data frame illustrating the problem >> ids<-c(rep(1234,5),rep(5436,3),rep(7864,4)) >> years<-c(seq(1990,1994,by=1),seq(1991,1

Re: [R] Summing by index

2010-07-30 Thread David Winsemius
On Jul 30, 2010, at 2:41 PM, steven mosher wrote: # build a sample data frame illustrating the problem ids<-c(rep(1234,5),rep(5436,3),rep(7864,4)) years<-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1)) data<-seq(14,25,by=1) data[6]<-NA DF<-data.frame(Id=ids,Year=years,Data=data)

[R] Summing by index

2010-07-30 Thread steven mosher
# build a sample data frame illustrating the problem ids<-c(rep(1234,5),rep(5436,3),rep(7864,4)) years<-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1)) data<-seq(14,25,by=1) data[6]<-NA DF<-data.frame(Id=ids,Year=years,Data=data) DF Id Year Data 1 1234 1990 14 2 1234 1