Very simple, renaming colnames with dplyr gives me an odd error.
library(dplyr)
df <- data.frame(var1=c("one","two","three"),var2=c(1,2,3))
df <-
df %>%
rename(var1=are.letters, var2=are.numbers)
Error: `are.letters`, `are.numbers` contains unknown variables
second try
df <- rename(df, var1=are.letters, var2=are.numbers)
Error: `are.letters`, `are.numbers` contains unknown variables
Wondering if quoting....
df <-
df %>%
rename('var1'='are.letters', 'var2'='are.numbers')
Error: `are.letters`, `are.numbers` contains unknown variables
Just made the same error. So, I'm converting @akrun's useful comment into an "answer."
To fix this, the new name should be on the left hand of the equal sign and the existing name should be on the right.
Like this:
df <- df %>%
rename(are.letters = var1, are.numbers = var2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With