Merge dataframes in R with different size and condition

前端 未结 2 1186
南旧
南旧 2021-01-21 15:43

I\'m trying to combine 2 csv files into one file. They have common id with different size. I used merge() but I got replicated data. I have the following data-frames;

         


        
2条回答
  •  情歌与酒
    2021-01-21 16:35

    Could you edit your problem and use dput to put your two df's into a form that would be easier for us to grab?

    Having said that, you need to do something like

    # NOT RUN
    library(tidyverse)
    RESULT <- data2 %>%
      mutate(comparison.id = str_detect(outcome.id, "^.+\\d+")) %>%
      inner_join(data1, by = c("SR.id", "comparison.id"))
    

提交回复
热议问题