Reputation: 1
I want to rename a column but, after running the code without errors, it doesn't change. The second variable of the data frame is 'Latest Name' and I want to change it to 'Name'.
Then I run:
rename(companies_names_industries, Name = 'Latest Name')
As you see below, the name has changed:
But then I check it again listing the variables names.
names(companies_names_industries)
And It is still the same, as you can see here:
Why does this happen? And how can I definitely change the name of the variable?
Upvotes: 0
Views: 6049
Reputation: 4400
you have to assign the data.frame to an object. your code will run but doesn't store it.
try:
library(dplyr)
df <- rename(companies_names_industries, Name = 'Latest Name')
names(df)
Upvotes: 1