I have a data frame, something like:
dataF <- data.frame(YEAR = 1996, MONTH = 10, LOCATION = "RIVER",stringsAsFactors = F)
which i pass to a function where i would like to create an expression that looks like:
YEAR == 1966 & MONTH == 10 & LOCATION == "RIVER"
which i'll then pass to dplyr::filter in the following statement
dataSet %>% dplyr::filter(YEAR == 1966 & MONTH == 10 & LOCATION == "RIVER")
Of course i want this function to be general, so i can pass it any data frame with different column labels. This data frame dataF is just an example
In my function I have been able to make a list of expressions where each element is calculated in a loop
cats <- names(dataF)
expres <- list()
for (i in 1:length(cats)) {
expres[[i]] <- rlang::expr(!!(rlang::sym(cats[i])) == !!(dataF[[cats[i]]]))
}
but i can not work out how to combine them all into one expression.