I want to remove data from a dataframe that is present in another dataframe. Let me give an example:
letters<-c('a','b','c','d','e')
numbers<-c(1,2,3,4,5)
list_one<-data.frame(letters,numbers)
I want to remove every row in list_one with matches in letters to this other dataframe:
letters2<-c('a','c','d')
list_two<-data.frame(letters2)
I should mention that I'm actually trying to do this with two large csv files, so I really can't use the negative expression - to take out the rows.
And create a final dataframe which only has the letters b and e and their corresponding numbers. How do I do this?
I'm new to R so it's hard to research questions when I'm not quite sure what key terms to search. Any help is appreciated, thanks!
A dplyr solution
library(dplyr)
list_one %>% anti_join(list_two)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With