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

View source: R/df.rename.R

df.renameR Documentation

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)

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, argument specification is checked.

Value

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

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

See Also

df.duplicated, df.unique, df.merge, df.rbind, df.sort

Examples

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

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

# 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"))

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to df.rename in misty...