I have the following dataframe:
library(dplyr)
df <- data.frame(gh225 = "foo1", gh765 = "foo2", gauskper = "foo3") %>%
rename_all(funs(stringr::str_replace_all(., "gh", "v")))
I want to use rename_all combined with if_else but I can't find the way, the logic would be something like this (but with variables):
if_else(stringr::str_detect(columns, "au"), "id_per", columns)
Put into words, I want to change the name gauskper to id_per.