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: Acres Bldgid 1 100.00 1 2 101.00 2 3 100.00 3 4 130.00 4 5 156.00 5 6 0.50 5 7 293.00 6 8 300.00 7 9 0.09 7 Becomes Acres Bldgid 1 100.00 1 2 101.00 2 3 100.00 3 4 130.00 4 5 156.50 5 7 293.00 6 8 300.09 7 dup<-unique(DF$Bldgid[duplicated(Bldgid)]) dupbuild<-DF[DF$Bldgid %in% dup,] dupbuild..dupareasum<-sum(dupbuild$Acres[duplicated(dupbuild$Bldgid)]) This sums the unique Ids of the duplicated records, not whati want. Thanks ahead of time JR -- View this message in context: http://www.nabble.com/Summing-identical-IDs-tp26118922p26118922.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.