[R] merge

Sarah Goslee sarah.goslee at gmail.com
Mon Apr 19 15:56:34 CEST 2010


What do you want to get?

And what exactly did you do?

Your question isn't very clear.

Sarah

On Mon, Apr 19, 2010 at 7:59 AM, n.vialma at libero.it <n.vialma at libero.it> wrote:
> 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??
>


-- 
Sarah Goslee
http://www.functionaldiversity.org


More information about the R-help mailing list