[R] merging with aggregating

From: Dubravko Dolic <Dubravko.Dolic_at_komdat.com>
Date: Wed 07 Dec 2005 - 00:22:31 EST


Dear List,

I have two data.frame of the following form:

A:

n V1 V2
1 12 0
2 10 8
3 3 8
4 8 4
6 7 3
7 12 0
8 1 0
9 18 0
10 1 0
13 2 0

B:

n V1 V2
1 0 2
2 0 3
3 1 9
4 12 8
5 2 9
6 2 9
8 2 0
10 4 1
11 7 1
12 0 1

Now I want to merge those frame to one data.frame with summing up the columns V1 and V2 but not the column n. So the result in this example would be:

AB:

n V1 V2
1 12 2
2 10 11
3 4 17
4 20 12
5 2 9
6 9 12
7 12 0
8 3 0
9 18 0
10 5 1
11 7 1
12 0 1
13 2 0

So Columns V1 and V2 are the sum of A und B while n has its old value. Notice that there are different rows in n of A and B.

I don't have a clue how to start here. Any hint is welcome.

Thanks

Dubravko Dolic
Munich
Germany



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Dec 07 00:59:14 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:29 EST