Skip to content
Prev 302765 / 398503 Next

summing and combining rows

Hello,

I tried with ddply

?ddply(dat1,.(Data,Plot,Lat,LatCat,Elevation,Type,Area,Density),summarize,sum(Stems))
? Data? Plot????? Lat LatCat Elevation??? Type???? Area? Density ..1
1? VTM 39C16 39.76282?? Lat6????? 1500 Conifer 751.5347? 0.00000?? 0
2? VTM 39C16 39.76282?? Lat6????? 1500 Conifer 751.5347 13.30611?? 1
3? VTM 39F11 39.57721?? Lat6?????? 500 Conifer 751.5347? 0.00000?? 0
4? VTM 39F13 39.56214?? Lat6????? 1500 Conifer 694.0784? 0.00000?? 4
5? VTM 39F14 39.54522?? Lat6?????? 900 Conifer 763.9850? 0.00000?? 2
6? VTM 39F14 39.54522?? Lat6?????? 900 Conifer 763.9850 13.08926?? 1


Results look same as in aggregate.
Suppose, if you take out density,

ddply(dat1,.(Data,Plot,Lat,LatCat,Elevation,Type,Area),summarize,sum(Stems))
? Data? Plot????? Lat LatCat Elevation??? Type???? Area ..1
1? VTM 39C16 39.76282?? Lat6????? 1500 Conifer 751.5347?? 1
2? VTM 39F11 39.57721?? Lat6?????? 500 Conifer 751.5347?? 0
3? VTM 39F13 39.56214?? Lat6????? 1500 Conifer 694.0784?? 4
4? VTM 39F14 39.54522?? Lat6?????? 900 Conifer 763.9850?? 3

I guess now it is summed.



A.K.






----- Original Message -----
From: Christopher R. Dolanc <crdolanc at ucdavis.edu>
To: arun <smartpink111 at yahoo.com>
Cc: 
Sent: Wednesday, August 8, 2012 1:19 PM
Subject: Re: [R] summing and combining rows

ok, so it looks like aggregate lists them separately unless everything 
in the 2 rows matches. Below, we have 2 plots where the density is 
different in Class3 than Class4, and these are not summed. Is that your 
understanding?

Thanks for your help.

Chris
On 8/7/2012 4:18 PM, arun wrote: