frev {admisc} | R Documentation |
Inverts the values of a factor
Description
Provides a reversed version of the values from a factor, for instance a Likert type response scale.
Usage
frev(x, labels = FALSE)
Arguments
x |
A factor |
labels |
Logical, invert the labels as well |
Details
The argument labels
can also be used for the levels of a factor.
Value
A factor of the same length as the original one.
Author(s)
Adrian Dusa
Examples
words <- c("ini", "mini", "miny", "moe")
variable <- factor(words, labels = words)
# inverts the values, preserving the labels' order
frev(variable)
# inverts both values and labels
frev(variable, labels = TRUE)
[Package admisc version 0.38 Index]