Learn R Programming

misty (version 0.6.7)

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
dat <- data.frame(a = c(3, 1, 6),
                  b = c(4, 2, 5),
                  c = c(7, 3, 1))

# Example 1: Rename variable b in the data frame 'dat' to y
df.rename(dat, from = "b", to = "y")

# Example 2: Rename variable a, b, and c in the data frame 'dat' to x, y, and z
df.rename(dat, from = c("a", "b", "c"), to = c("x", "y", "z"))

Run the code above in your browser using DataLab