0

I have two data.frames The first data frame is as follows:

>df1
Names Signal  Transport
dd_1    Y       Y
dd_2    N       N
dd_3    Y       N
dd_4    Y       Y

The second data.frame like follows:

>df2
Names   Details   Description   Process  
dd_1     nadh        zoll        cytopl
dd_3     mol2        hilt        transport
dd_5     mol3        tamr        secretion  
dd_7     gapdh       lapm        lores
dd_9     kitp        ring-t      N_terminal 

I would like to combine this two dataframes into a single data frame like this

 Names   Details   Description   Process      Signal     Process
    dd_1     nadh        zoll        cytopl        Y           Y 
    dd_2      NA          NA           NA          N           N
    dd_3     mol2        hilt        transport     Y           N
    dd_4      NA          NA           NA          Y           Y
    dd_5     mol3        tamr        secretion     NA          NA
    dd_7     gapdh       lapm        lores         NA          NA 
    dd_9     kitp        ring-t      N_terminal    NA          NA

I used the following R-code

merge(df1,df2,by="Names",all=T)

I tried using merge but it introduced NAs to the entire row though there are values for that particular column. I need merge this two data.frame and introduce NA for those column of the data.frames which doesnt have any value. I got the following output

Names   Details   Description   Process      Signal     Process
    dd_1     nadh        zoll        cytopl        Y           Y 
    dd_2      NA          NA           NA          NA          NA
    dd_3     mol2        hilt        transport     Y           N
    dd_4      NA          NA           NA          NA          NA
    dd_5      NA          NA           NA          NA          NA
    dd_7      NA          NA           NA          NA          NA 
    dd_9      NA          NA           NA          NA          NA

Kindly guide me

Dinesh
  • 643
  • 5
  • 16
  • 31

0 Answers0