text:
Q: subset data.frame by combination of two variable in R (another df) I would like to subset data.frame by combination of two factors from another data.frame. Toy example below:
df <- data.frame(ind=seq(748,867), A=rep(1:12, 10),
           val1=runif(120, 2,7), val2=runif(120, 42,70))
new <- data.frame(A=c(3,4,5), val1=c(1,6,6.8))

I need to select observations df based combination of conditionals in new
I have tried:
> t1 <- subset(df, df$A %in% new$A & df$val1 > new$val1)

> t1
    ind A     val1     val2
4   751 4 5.991882 55.02130
16  763 4 6.664002 60.70389
28  775 4 3.952898 47.50801
29  776 5 6.448094 55.26087
40  787 4 3.916499 67.01201
52  799 4 5.475465 54.12958
64  811 4 4.641724 53.29380
76  823 4 6.186887 48.41644
88  835 4 2.757776 57.76709
89  836 5 6.290239 46.08715
100 847 4 3.160457 67.57916
112 859 4 3.988948 64.71397
113 860 5 6.569812 42.70852

I expected to get a set of observation with parameters:
A==3 & val1>1; A==4 & val1>6; A==5 &val1>6.8
Any ideas?

A: You could do this:
subset(merge(df,new,by="A",all.x=TRUE), val1.x > val1.y)

Merge ensures that the two vectors compared are the same length.
To avoid any modification to df (renaming of val1, adding another variable):
names(new)[2] <- "val1.y"
subset(merge(df,new,by="A",all.x=TRUE), val1 > val1.y)[-5]