frev: Inverts the values of a factor

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


admisc documentation built on April 3, 2025, 7:55 p.m.

Related to frev in admisc...