'Renaming a variable name in r
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?
Solution 1:[1]
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mike |


