match two data.frames based on multiple columns

后端 未结 3 1556
被撕碎了的回忆
被撕碎了的回忆 2021-01-11 17:19

My head stands still at the moment. I would like to match/extract data from a larger data.frame (df) based on the columns in a smaller data.frame (mdf). What I\'m getting st

3条回答
  •  礼貌的吻别
    2021-01-11 17:42

    Another way would be:

    library(dplyr)
    inner_join(df, mdf)
    
    #Joining by: c("car_1", "car_2")
    #              car_1          car_2  mpg cyl disp
    #1        Datsun 710 Ford Pantera L 22.8   4  108
    #2    Hornet 4 Drive   Ferrari Dino 21.4   6  258
    #3 Hornet Sportabout  Maserati Bora 18.7   8  360
    #4           Valiant     Volvo 142E 18.1   6  225
    

提交回复
热议问题