I would like to merge 2 data frames based on multiple conditions.
DF1 <- data.frame(\"col1\" = rep(c(\"A\",\"B\"), 18), \"col2\" = rep(c
By using all.x=TRUE all rows of DF1 are kept then adjust condition in filter as follows:
iMed=merge(DF1,DF2,by.x=c('col1','col2'),by.y=c('col1','col2'),all.x=TRUE) Res=iMed[is.na(iMed[,'min'])|is.na(iMed[,'max'])|(iMed[,'value']<=iMed[,'max'] & iMed[,'value']>=iMed[,'min'] ),]