I am trying to filter() a dataframe using dplyr and I would like to filter based on a custom range specified by a list/ values in another data frame.
An example of what I am trying to do is follows. Any help will be greatly appreciated.
al<- a$source- t
ah<- a$source + t
b= data.frame(source= c(1:50))
#filtering based on a list ( this works)
c<- b %>% filter(source %in% d)
#(filtering based on a fixed range, this works)
c<- b %>% filter(between(source,2,5))
#I am stuck here when I try to pass a series of values in between()
c<- b %>% filter(between(source,al,ah))
I think the problem is that
between expects a single value for the boundary conditions.
You could try to do:
c<- b %>% filter(source > al & source < ah)
However, I find this a little weird because the
ah will be recycled to match the size of