rename: Rename variables

Description Usage Arguments Details Value Author(s) Examples

View source: R/rename.R

Description

Rename variables using formulas

Usage

1
rename(from, formula, ...)

Arguments

from

a data.frame object with variables

formula

a formula indicating the operation to create new varibles. Look at the detail section for explanantion.

...

further arguments

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

Value

The original data.frame with changed column names

Author(s)

Alessio Serafini

Examples

1
2
3
4
5
data("airquality")
dt <- airquality

head(rename(from = dt, Ozone ~ Ozone1))
head(rename(from = dt, Ozone + Wind ~ Ozone_new + Wind_new))

dformula documentation built on July 2, 2020, 3:37 a.m.