Learn R Programming

misty (version 0.7.0)

df.rename: Rename Columns in a Matrix or Variables in a Data Frame

Description

This function renames columns in a matrix or variables in a data frame by specifying a character string or character vector indicating the columns or variables to be renamed and a character string or character vector indicating the corresponding replacement values.

Usage

df.rename(x, from, to, check = TRUE)

Value

Returns a matrix or data frame with renamed columns or variables.

Arguments

x

a matrix or data frame.

from

a character string or character vector indicating the column(s) or variable(s) to be renamed.

to

a character string or character vector indicating the corresponding replacement values for the column(s) or variable(s) specified in the argument name.

check

logical: if TRUE (default), argument specification is checked.

Author

Takuya Yanagida takuya.yanagida@univie.ac.at

See Also

df.duplicated, df.merge, df.move, df.rbind, df.sort, df.subset

Examples

Run this code
# Example 1: Rename 'cyl' in 'mtcars' to 'cylinder'
df.rename(mtcars, from = "cyl", to = "cylinder")

# Example 2: Rename 'cyl' and 'wt' in 'mtcars' to 'cylinder' and 'weight'
df.rename(mtcars, from = c("cyl", "wt"), to = c("cylinder", "weight"))

Run the code above in your browser using DataLab