[R] sum two columns with same value

Alfredo Alessandrini
Sat, 17 Oct 2009 07:36:50 -0000

Hi,

I've two dataframe:

> snag_totale
  AREA   snag_ha
1    2  1.628128
2    3 10.274249
3    4  2.778503
4    5 73.764307
5    7 12.015985
> log_totale
  AREA    log_ha
1    1  22.29846
2    2  17.16889
3    3  48.80377
4    4 144.18996
5    5  70.30962
6    6  61.81850
7    7  13.24876
>

How can I obtain a new data.frame, by the sum of value "snag_ha" +
"log_ha" in the same "AREA"?

Like this:

   AREA       sum
1    1  22.29846
2    2  18.79702
3    3  59.07801
4    4 146.96847
5    5 144.07392
6    6  61.81850
7    7  25.26474