finvert: Inverts the values of a factor

finvertR 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)


admisc documentation built on Sept. 12, 2024, 6:27 a.m.

Related to finvert in admisc...