0

I'd like the code to return the remaining rows after subsetting from another dataframe.

Month = c('January','February','March','April','May','June')
Names = c("Jack", "Steve", "CJ", "Polar", "Ren", "Vent")
Color = c("Red", "Grey", "Yellow", "Blue", "Yellow", "Pink")
df= data.frame(Month, Names, Color)

Month = ""
Names = c("Jack", "Steve", "CJ", "Polar", "Ren", "Vent", "Keegan", "Fabian")
Color = c("Red", "Grey", "Yellow", "Blue", "Yellow", "Pink", "Pink", "Red")
df2 = data.frame(Month, Names, Color)

df$Month is filled up while df2$Month will be an empty column. Essentially what I would like to do is to subtract df from df2. And it should return me

    
Month   Names  Color
1       Keegan  Pink
2       Fabian  Red
Werner Hertzog
  • 2,002
  • 3
  • 24
  • 36
realbeast91
  • 176
  • 9
  • This is a one-liner: `dplyr::anti_join(df2, df, by=c("Names", "Color"))` – Taufi Nov 15 '20 at 12:08
  • Oh its called an anti join, thanks for the help pal! @Taufi – realbeast91 Nov 15 '20 at 12:51
  • Hi lets say that I have a lots of columns, it's going to be a hassle for me to name out all the column names and put them into the line, is there a way that will help me identify all the column names at once without entering them manually? @Taufi – realbeast91 Nov 15 '20 at 12:55
  • Type `?colnames`. I think that is what you are looking for. – Taufi Nov 15 '20 at 13:01
  • Hi thanks for the reply, yes I tried using colnames(df) and colnames(df2) but both of them return me 8 rows of vectors. I will settle with the previous solution for now, thanks again! @taufi – realbeast91 Nov 15 '20 at 15:00

0 Answers0