d1 <- data.frame(y1=c(1,2,3), y2=c(4,5,6), y3=c(8,8,8), y4=c(1,1,1))
d2 <- data.frame(y1=c(3,2,1), y2=c(6,5,4), y3=c(4,4,4), y4=c(10,10,10))
d3 <- data.frame(y1=c(6,5,4), y2=c(3,2,1), y3=c(8,8,8), y4=c(1,1,1))
d4 <- data.frame(y1=c(9,9,9), y2=c(8,8,8), y3=c(8,8,8), y4=c(1,1,1))
dat = mget(paste0("d", 1:4))
From this list I want to keep the dataframe(s) where (1) y3 is between 1 and (2) 5 and y4 is between 5 and 11.
Values in y3 and y4 are the same in each dataframe.
The final output will be:
> dat
$d2
y1 y2
1 3 6
2 2 5
3 1 4