[R] merging dataframes with diffent rownumbers

Michael Dewey info at aghmed.fsnet.co.uk
Mon Jun 18 12:52:14 CEST 2007


At 09:09 18/06/2007, Thomas Hoffmann wrote:
>Dear R-Helpers,
>
>I have following problem:
>
>I do have two data frames dat1 and dat2 with a commen column BNUM 
>(long integer). dat1 has a larger number of BNUM than dat2 and 
>different rows of dat2 have equal BNUM. The numbers of rows in dat1 
>and dat2 is not equal.  I applied the  tapply-function to dat2 with 
>BNUM as index. I would like to add the columns from dat1 to the results of
>
>b.sum <- tapply(dat2, BNUM, sum).
>
>However the BNUM of b.sum are only a subset of the dat1.
>
>Does anybody knows a elegant way to solve the problem?

If I understand you correctly
?merge
should help you here

>Thanks in advance
>
>Thomas H.
>
>

Michael Dewey
http://www.aghmed.fsnet.co.uk



More information about the R-help mailing list