Merge r brings error “'by' must specify uniquely valid columns”

后端 未结 2 703
名媛妹妹
名媛妹妹 2021-01-03 20:43

R doesn\'t like me today...

I have two tables asembled via cbind(). Tab 1 (dwd_nogap) is

  x1                 col1_x1       col2_x1          


        
相关标签:
2条回答
  • 2021-01-03 21:30

    Rather give names of the column on which you want to merge:

    exporttab <- merge(x=dwd_nogap, y=dwd_gap, by.x='x1', by.y='x2', fill=-9999)
    
    0 讨论(0)
  • 2021-01-03 21:40

    This is what I tried for a right outer join [as per my requirement]:

    m1 <- merge(x=companies, y=rounds2, by.x=companies$permalink, 
                by.y=rounds2$company_permalink, all.y=TRUE)
    # Error in fix.by(by.x, x) : 'by' must specify uniquely valid columns
    m1 <- merge(x=companies, y=rounds2, by.x=c("permalink"), 
                by.y=c("company_permalink"), all.y=TRUE)
    

    This worked.

    0 讨论(0)
提交回复
热议问题