Selecting rows from a data frame from combinations of lists [duplicate]
This question already has an answer here: Removing one table from another in R [closed] 3 answers I have a dataframe, dat: dat<-data.frame(col1=rep(1:4,3), col2=rep(letters[24:26],4), col3=letters[1:12]) I want to filter dat on two different columns using ONLY the combinations given by the rows in the data frame filter : filter<-data.frame(col1=1:3,col2=NA) lists<-list(list("x","y"),list("y","z"),list("x","z")) filter$col2<-lists So for example, rows containing (1,x) and (1,y), would be selected, but not (1,z),(2,x), or (3,y). I know how I would do it using a for loop: #create a frame to drop