Skip to content
Prev 302591 / 398503 Next

summing and combining rows

Hello,

I have a data set that needs to be combined so that rows are summed by a 
group based on a certain variable. I'm pretty sure rowsum() or rowsums() 
can do this but it's difficult for me to figure out how it will work for 
my data based on the examples I've read.

My data are structured like this:

Plot    SizeClass    Stems
12       Class3            1
12       Class4            3
17       Class3            5
17       Class4            2

I simply want to sum the size classes by plot and create a new data 
frame with a size class called "Class34" or with the SizeClass variable 
removed. I actually do have other size classes that I want to leave 
alone, but combine 3 and 4, so if I could figure out how to do this by 
creating a new class, that would be preferable.

I've also attached a more detailed sample of data.

Thanks,
Chris Dolanc