Rename | R Documentation |
Rename
changes the names of a named object.
Rename(x, ..., gsub = FALSE, fixed = TRUE, warn = TRUE)
x |
Any named object |
... |
A sequence of named arguments, all of type character |
gsub |
a logical value; if TRUE, |
fixed |
a logical value, passed to |
warn |
a logical value; should a warning be issued if those names to change are not found? |
This function changes the names of x
according to the
remaining arguments.
If gsub
is FALSE, argument tags are the old
names, the values are the new names.
If gsub
is TRUE, arguments are substrings of the names
that are substituted by the argument values.
The object x
with new names defined by the ... arguments.
This function was previously published in the package memisc as rename
and has been integrated here without logical changes.
Martin Elff <melff@essex.ac.uk>
SetNames
, Recode
for recoding of a factor (renaming or combining levels)
x <- c(a=1, b=2)
Rename(x, a="A", b="B")
str(Rename( iris,
Sepal.Length="Sepal_Length",
Sepal.Width ="Sepal_Width",
Petal.Length="Petal_Length",
Petal.Width ="Petal_Width"
))
str(Rename(iris, .="_", gsub=TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.