I would like to add a prefix to the columns of my dataset if the column names are not contained in a character vector called untouch_vars.
After looking at the help page of rename_at, I tried the following lines of code:
data("iris")
untouch_vars <- c("Sepal.Length", "Species", "Foo", "Fii")
iris %>%
rename_at(vars(-untouch_vars), ~str_c("HEY_", .))
but it doesn't work since Foo and Fii are not present in the iris dataset. In fact, I get the following error:
Error: Unknown columns `Foo` and `Fii`
Call `rlang::last_error()` to see a backtrace
Since I have several datasets and I do not want to create a custom vector of to-be-excluded variables for each of them, is there a way to make my intent happen?