[R] merging with aggregating

2005-12-06 Thread Dubravko Dolic
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

Re: [R] merging with aggregating

2005-12-06 Thread Marc Schwartz
On Tue, 2005-12-06 at 14:22 +0100, Dubravko Dolic wrote: 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

Re: [R] merging with aggregating

2005-12-06 Thread Dubravko Dolic
. Dubro -Ursprüngliche Nachricht- Von: Marc Schwartz [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 6. Dezember 2005 15:11 An: Dubravko Dolic Cc: r-help@stat.math.ethz.ch Betreff: Re: [R] merging with aggregating On Tue, 2005-12-06 at 14:22 +0100, Dubravko Dolic wrote: Dear List, I

Re: [R] merging with aggregating

2005-12-06 Thread Adaikalavan Ramasamy
m1 - cbind( n=c(1,2,3,4,6,7,8,9,10,13), v1=c(12,10,3,8,7,12,1,18,1,2), v2=c(0,8,8,4,3,0,0,0,0,0) ) m2 - cbind( n=c(1,2,3,4,5,6,8,10,11,12), v1=c(0,0,1,12,2,2,2,4,7,0), v2=c(2,3,9,8,9,9,0,1,1,1) ) m.all - merge(m1, m2, by=n, all=T) n v1.x v2.x v1.y v2.y

Re: [R] merging with aggregating

2005-12-06 Thread Marc Schwartz (via MN)
On Tue, 2005-12-06 at 15:19 +0100, Dubravko Dolic wrote: Hi all, the moment you hit the 'send' button you know the answer... I approached a solution similar to this one given by Marc. But maybe there is a better one? Even because this operation is done in a for-loop during which R gets

Re: [R] merging with aggregating

2005-12-06 Thread Pierre Kleiber
Here's a solution that uses aggregate(), as suggested in the subject of this thread. m1 - cbind( n=c(1,2,3,4,6,7,8,9,10,13), v1=c(12,10,3,8,7,12,1,18,1,2), v2=c(0,8,8,4,3,0,0,0,0,0) ) m2 - cbind( n=c(1,2,3,4,5,6,8,10,11,12), v1=c(0,0,1,12,2,2,2,4,7,0),