R: merge based on multiple conditions (with non-equal criteria)

后端 未结 5 758
陌清茗
陌清茗 2021-01-01 05:26

I would like to merge 2 data frames based on multiple conditions.

DF1 <- data.frame(\"col1\" = rep(c(\"A\",\"B\"), 18),
                  \"col2\" = rep(c         


        
5条回答
  •  离开以前
    2021-01-01 05:45

    You can do it in two steps:

    final <- merge(DF1,DF2,by=c("col1","col2"),all.x = T)
    final$data <- ifelse(final$data>=final$min & final$data<=final$max,final$data,"NULL")
    

提交回复
热议问题