Change labels of factors or labelled objects
Function relabel
changes the labels of a factor or any object
that has a names
, labels
, value.labels
, or variable.labels
attribute.
Function relabel4
is an (internal) generic which is called by relabel
to handle S4 objects.
## Default S3 method: relabel(x, ..., gsub = FALSE, fixed = TRUE, warn = TRUE) ## S3 method for class 'factor' relabel(x, ..., gsub = FALSE, fixed = TRUE, warn = TRUE) ## S4 method for signature 'item' relabel4(x, ...) # This is an internal method, see details. # Use relabel(x, \dots) for 'item' objects
x |
An object with a |
... |
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; if TRUE, a warning is issues if a a change of labels was unsuccessful. |
This function changes the names or labels of x
according to the
remaining arguments.
If gsub
is FALSE, argument tags are the old
labels, the values are the new labels.
If gsub
is TRUE, arguments are substrings of the labels
that are substituted by the argument values.
Function relabel
is S3 generic. If its first argument is an S4 object,
it calls the (internal) relabel4
generic function.
The object x
with new labels defined by the ... arguments.
f <- as.factor(rep(letters[1:4],5)) levels(f) F <- relabel(f, a="A", b="B", c="C", d="D" ) levels(F) f <- as.item(f) labels(f) F <- relabel(f, a="A", b="B", c="C", d="D" ) labels(F) # Since version 0.99.22 - the following also works: f <- as.factor(rep(letters[1:4],5)) levels(f) F <- relabel(f, a=A, b=B, c=C, d=D ) levels(F) f <- as.item(f) labels(f) F <- relabel(f, a=A, b=B, c=C, d=D ) labels(F)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.