I am trying to write a function that uses dplyr's filter_at. My dataset includes columns named pr1:pr15 (all chr variables with values such as "8201" or "0599"), and I am trying to build a filter that includes any row that has a value x in any col p1:pr15
This is what I've tried:
my_filterfunc <- function(data, x) {data %>%
filter_at(vars(starts_with(regex("pr[0:9]"))), any_vars(. == "x"))}
When I try to run this function as such:
test <- my_fiterfunc(my_tibble, x = "8201")
I get an error: Error: .predicate has no matching columns
Even though I know that there are matching columns