0

I'm trying to use a dplyr function:

rename_all(paste0, "_x")

which adds _x to every column in the DF (by keeping its original name + _x) It works great but I want to exclude a column from this function using !matches() or something. I'm unable to combine these two functions.

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
Ido
  • 201
  • 1
  • 8
  • Please make the question [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – NelsonGon May 26 '20 at 12:07

1 Answers1

0

You can use rename_at:

library(dplyr)
rename_at(df, vars(!contains("string_to_exclude")), list( ~paste0(., "_x")))
Ahorn
  • 3,686
  • 1
  • 10
  • 17