Data Science Desktop Survival Guide
by Graham Williams |
|||||
Rename Variables |
20201202 We can rename variables within a pipeline. To normalise the variables automatically see Section 9.13. If we have a set of new names that we want to use instead of the original names or instead of the automatically normalised names, then use dplyr::rename() in a pipeline.
The original variable names are obtained using base::names():
names(ds)
We can rename the variables based on their name using dplyr::rename():
|
# Rename the variables based on their names.
ds %>% rename(date=Date, location=Location, min_temp=MinTemp, max_temp=MaxTemp)
|