df.rename | R Documentation |
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.
df.rename(x, from, to, check = TRUE)
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 |
check |
logical: if |
Returns a matrix or data frame with renamed columns or variables.
Takuya Yanagida takuya.yanagida@univie.ac.at
df.duplicated
, df.merge
,
df.move
, df.rbind
,
df.sort
,
df.subset
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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.