I have two different dataframes, df1 and df2. I need to delete the observations from df1 that are within df2. I was thinking of doing a loop through every row and column and check if the value is within df2 and if it is, delete it. I was wondering if maybe there is a faster way to do so. This is what I have until now
`for(i in 1:nrow(df1)){
for(j in 1:ncol(df1)){
if(df[i,j] %in% df2){
df[i,j] <- 'NA'
}
}
}`
I do not want to delete the whole row, only the values that are in df2 and shift cells to the left. and then delete all the NA values. Thank you very much.