Debian Codegraph @

man/rename.Rd

raw
1 \name{rename}
2 \alias{rename}
3 \title{Change Names of a Named Object}
4 \description{
5 \code{rename} changes the names of a named object.
6 }
7 \usage{
8 rename(x, \dots, gsub = FALSE, fixed = TRUE, warn = TRUE)
9 }
10 \arguments{
11 \item{x}{Any named object}
12 \item{\dots}{A sequence of named arguments, all of type character}
13 \item{gsub}{a logical value; if TRUE, \code{\link{gsub}} is used to change the
14 row and column labels of the resulting table.
15 That is, instead of substituting whole names, substrings of the
16 names of the object can changed.
17 }
18 \item{fixed}{a logical value, passed to \code{\link{gsub}}. If TRUE,
19 substitutions are by fixed strings and not by regular expressions.}
20 \item{warn}{a logical value; should a warning be issued if
21 those names to change are not found?}
22 }
23 \details{
24 This function changes the names of \code{x} according to the
25 remaining arguments.
26 If \code{gsub} is FALSE, argument tags are the \emph{old}
27 names, the values are the new names.
28 If \code{gsub} is TRUE, arguments are substrings of the names
29 that are substituted by the argument values.
30 }
31
32 \value{
33 The object \code{x} with new names defined by the \dots arguments.
34 }
35
36 \examples{
37 x <- c(a=1, b=2)
38 rename(x,a="A",b="B")
39 # Since version 0.99.22 - the following also works:
40 rename(x,a=A,b=B)
41
42 str(rename(iris,
43 Sepal.Length="Sepal_Length",
44 Sepal.Width ="Sepal_Width",
45 Petal.Length="Petal_Length",
46 Petal.Width ="Petal_Width"
47 ))
48 str(rename(iris,
49 .="_"
50 ,gsub=TRUE))
51
52 # Since version 0.99.22 - the following also works:
53 str(rename(iris,
54 Sepal.Length=Sepal_Length,
55 Sepal.Width =Sepal_Width,
56 Petal.Length=Petal_Length,
57 Petal.Width =Petal_Width
58 ))
59 }
60 \keyword{manip}