I wish to do exactly this: [Take dates from one dataframe and filter data in another dataframe - R](https://stackoverflow.com/questions/36190921/take-dates-from-one-dataframe-and-filter-data-in-another-dataframe-r)

except without joining, as I am afraid that after I join my data the result will be too big to fit in memory, prior to the filter.

Here is sample data:

```
tmp_df <- data.frame(a = 1:10)

```

I wish to do an operation that looks like this:

```
lower_bound <- c(2, 4)
upper_bound <- c(2, 5)
tmp_df %>%
    filter(a >= lower_bound & a <= upper_bound) # does not work as <= is vectorised inappropriately

```

and my desired result is:

```
> tmp_df[(tmp_df$a <= 2 & tmp_df$a >= 2) | (tmp_df$a <= 5 & tmp_df$a >= 4), , drop = F] 
# one way to get indices to subset data frame, impractical for a long range vector
  a
2 2
4 4
5 5

```

My problem with memory requirements (with respect to the join solution linked) is when `tmp_df` has many more rows and the `lower_bound` and `upper_bound` vectors have many more entries. A `dplyr` solution, or a solution that can be part of pipe is preferred.