[R] merge

n.vialma at libero.it n.vialma at libero.it
Mon Apr 19 13:59:43 CEST 2010


I have a problem with the merge function.
I have to merge two big dataframes which  look like the following example.The 
problems is that I get duplicated rows.

CODPROD       N1           N3           N4
23                       3               55                 4
24                       5              67                36
25                      3               73                 24



second data frame


CODPROD                  N1              N2       
30                                   34               45
45                                   0                    78
65                                    0                    56


The result that I get its like:

CODPROD                 N1       N2         N3            N4      N1.1
23                                 3           NA        55            
4             3
24                                 5           NA        67           
36           0
25                                 3           NA        73           
24             0
30                                 34         45          NA           
NA         0
45                                  0          78          NA           
NA           0
65                                  0           56          NA            
NA     .   0

So N1.1 is a duplication of N1.I think I could solve the problems by 
specifying  the same columns but I have a lot of colums which have the same 
names in the two dataframe so I think its not the right way to solve it.

Anyone knows how to avoid duplication??



More information about the R-help mailing list