Skip to content

Instantly share code, notes, and snippets.

View petzi53's full-sized avatar

Peter Baumgartner petzi53

View GitHub Profile
@grayskripko
grayskripko / dplyr_rename.R
Last active March 8, 2022 10:46
Dplyr rename all columns with character vector
x <- data.frame(a=1, b=2)
x %>% rename_at(vars(names(.)), ~letters[3:4])
x %>% rename_all(~letters[3:4])
x %>% rename_all(funs(str_c('prefix_', .)))
x %>% rename_at(vars(-starts_with("a")), ~str_c(., "_b")) # approx.