I have a dataframe containing unique values of two variables:
df <- data.frame(V1=LETTERS,V2=c(1:26))
I'd like to filter another dataframe for values in df$V1 and corresponding value of df$V2. This is what I have tried which obviously doesn't produce the desired result:
df2 <- data.frame(V1=c('A','A','B','B','A'),
V2=c(1,2,2,3,4))
df2 %>% filter(V1 %in% unique(df$V1) & V2 %in% unique(df$V2))
The result I am expecting post filtering is:
V1 V2
1 A 1
2 B 2
How do I achieve this?