finvert | R Documentation |
Useful function to invert the values from a categorical variable, for instance a Likert response scale.
finvert(x, levels = FALSE)
x |
A categorical variable (a factor) |
levels |
Logical, invert the levels as well |
A factor of the same length as the original one.
Adrian Dusa
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.