I've been trying for hours with this one. I have a dataset with two columns, let's call them V1 and V2.I also have a list of imporatant V1 values - Vx. I managed to acquire a subset of V1 with intersect function, so:
intersect <- intersect(df$V1,Vx)
Now I am desperately trying to get V2 values, corresponding to this subset. I've tried with
subset <- df[intersect(df$V1,Vx),]
But it returns me values, which are all NAs. So to explain with another case: I have a dataset
V1 V2
a54 hi
bc85 hk
sdx637 hi
vbd435 hk
And also a list, containing
l <- c("a54","sdx637")
What I am trying to get is:
V1 V2
a54 hi
sdx637 hi
As I said, the code I've been using gives me all NAs, are there any alternatives? Thank you very much.