I want to use the str_detect
function passing a variable as the first argument. Meaning this could theoretically look something like this.
# create the variable
var = names(mtcars)[1]
mtcars %>%
mutate(
new_var = case_when(str_detect(var, "^2"), "two", "other")
)
Now I'm not sure how to insert the variable var
correctly into the str_detect
function. I guess some tidy-eval is necessary, but I'm not sure....