0

I am getting an error for Error: unexpected '}' in "}" when trying to rename column names using paste0().

For example:

df %>% 
    rename(., paste0("text", "index") = old)

Am I supposed to be using something other than = for this?

Bear25
  • 33
  • 5

1 Answers1

2

Try

df %>% 
  rename(., !!paste0("text", "index") := old)
Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98
  • Thank you! This works. May I know the significance of ```!!``` and the use of ```:=``` in this context? Or any articles that may point me towards learning about them. I've tried looking for this previously but don't think I am looking for the right articles. – Bear25 Dec 15 '20 at 13:00
  • 1
    Sure, may I suggest you visit the question that has been linked above? Also google for "quasiquotation" and "lazy evaluation". – Martin Schmelzer Dec 15 '20 at 13:05
  • Absolutely. I'll probably need to spend some time parsing through the thread as most of it seems to be beyond my current capabilities. But it looks very helpful! Thank you. – Bear25 Dec 15 '20 at 13:24