Data Frame Operations: Filter Common Rows and Delete Rows of Multiple Data Frames

     dfA <- data.frame(Efficiency=c(7,2,8,9), Value=c(3, 4, 7, 8))
     dfB <- data.frame(Efficiency=c(7,2,4,2,8,9), Value=c(3, 4, 4, 1, 7, 8))
     dfC <- data.frame(Efficiency=c(7,9), Value=c(3, 8))

      

I want to get common dfA and dfB lines. From the resulting data.frame file, I want to remove lines that have the same values ​​as dfC. dfA + dfB (common lines only) - dfC (overlapping lines)

+3


source to share


1 answer


this should work:

library(dplyr)
inner_join(dfA, dfB) %>% anti_join(dfC)

      



which gives:

  Efficiency Value
1          8     7
2          2     4

      

+4


source







All Articles