finvert {admisc} | R Documentation |
Inverts the values of a factor
Description
Useful function to invert the values from a categorical variable, for instance a Likert response scale.
Usage
finvert(x, levels = FALSE)
Arguments
x |
A categorical variable (a factor) |
levels |
Logical, invert the levels as well |
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, levels = words)
# inverts the value, preserving the levels
finvert(variable)
# inverts both values and levels
finvert(variable, levels = TRUE)
[Package admisc version 0.35 Index]