I'm a beginner at R. I want to remove all the rows of my data frame, where the column value of the row matches a value in the the vector. For example:
df = data.frame(A = c(a1, a2, a3), B = c(b1, b2, b3), C = c(c1, c2, c3))
vec = c("a43", "a2", "a7", ...)
So here row 2 should be removed because a2 from column A matches value a2 in vec (only column A is to be compared). How can I do this?
Edit:
All relevant vectors are character vectors, if that makes a difference.
I have tried the following:
1. df1 = subset(df, !(df$A %in% vec))
2. df1 = subset(df, !(A %in% vec))
3. df1 = df[-which(df$A %in% vec),]
1. & 2. give me df1 = df2 , though there actually are a few matches.
3. gave me an empty dataframe in df1