Rename variables
rename.Rd
Rename variables using formulas
Details
The formula is composed of two part:
column_names ~ new_variables_name
the left-hand side select the columns to change the names, and the right-hand the new names of the selected columns
For example:
column_names1 + column_names2 ~ new_variables_name1 + new_variables_name2
the name of the column 1
and the name of the column 2
are changed in new_variables_name1
and new_variables_name2
Examples
data("airquality")
dt <- airquality
head(rename(from = dt, Ozone ~ Ozone1))
#> Ozone1 Solar.R Wind Temp Month Day
#> 1 41 190 7.4 67 5 1
#> 2 36 118 8.0 72 5 2
#> 3 12 149 12.6 74 5 3
#> 4 18 313 11.5 62 5 4
#> 5 NA NA 14.3 56 5 5
#> 6 28 NA 14.9 66 5 6
head(rename(from = dt, Ozone + Wind ~ Ozone_new + Wind_new))
#> Ozone_new Solar.R Wind_new Temp Month Day
#> 1 41 190 7.4 67 5 1
#> 2 36 118 8.0 72 5 2
#> 3 12 149 12.6 74 5 3
#> 4 18 313 11.5 62 5 4
#> 5 NA NA 14.3 56 5 5
#> 6 28 NA 14.9 66 5 6