[R] Summing identical IDs

2009-10-29 Thread PDXRugger
Hello All, I would like to select records with identical IDs then sum an attribute then and return them to the data frame as a single record. Please consider Acres<-c(100,101,100,130,156,.5,293,300,.09) Bldgid<-c(1,2,3,4,5,5,6,7,7) DF=cbind(Acres,Bldgid) DF<-as.data.frame(DF) So that:

Re: [R] Summing identical IDs

2009-10-29 Thread Dimitris Rizopoulos
one option is the following: Acres <- c(100,101,100,130,156,.5,293,300,.09) Bldgid <- c(1,2,3,4,5,5,6,7,7) DF <- data.frame(Acres, Bldgid) aggregate(DF, list(Bldgid), sum) I hope it helps. Best, Dimitris PDXRugger wrote: Hello All, I would like to select records with identical IDs then

Re: [R] Summing identical IDs

2009-10-29 Thread Jorge Ivan Velez
Hi JR, Try also with(DF, tapply(Acres, Bldgid, sum) ) HTH, Jorge On Thu, Oct 29, 2009 at 3:03 PM, PDXRugger <> wrote: > > Hello All, > I would like to select records with identical IDs then sum an attribute > then and return them to the data frame as a single record. Please consider > > >

Re: [R] Summing identical IDs

2009-10-29 Thread PDXRugger
Terrific help thank you. dupbuild<-aggregate(DF$Acres, list(Bldgid), sum) This line worked best. Now im going to challenge everyone (i think?) Consider the following: Acres<-c(100,101,100,130,156,.5,293,300,.09,100,12.5) Bldgid<-c(1,2,3,4,5,5,6,7,7,8,8) Year<-c(1946,1952,1922,1910,1955,1955,

Re: [R] Summing identical IDs

2009-10-30 Thread David Winsemius
On Oct 29, 2009, at 5:23 PM, PDXRugger wrote: Terrific help thank you. dupbuild<-aggregate(DF$Acres, list(Bldgid), sum) This line worked best. Now im going to challenge everyone (i think?) Consider the following: Acres<-c(100,101,100,130,156,.5,293,300,.09,100,12.5) Bldgid<-c(1,2,3,4,5,5,6

Re: [R] Summing identical IDs

2009-10-30 Thread PDXRugger
David, You are correct. I think the frist two assumptions can be thrown out and only the latter two (c,d) can be considered. So how would i combine Acres for matching Bldgids based on assumptions c,d? David Winsemius wrote: > > > On Oct 29, 2009, at 5:23 PM, PDXRugger wrote: > >> >> Terr

Re: [R] Summing identical IDs

2009-10-31 Thread David Winsemius
On Oct 30, 2009, at 3:29 PM, PDXRugger wrote: David, You are correct. I think the frist two assumptions can be thrown out and only the latter two (c,d) can be considered. So how would i combine Acres for matching Bldgids based on assumptions c,d? I also think your requested output f