reverse {quest}R Documentation

Reverse Code a Numeric Vector

Description

reverse reverse codes a numeric vector based on minimum and maximum values. For example, say numerical values of response options can range from 1 to 4. The function will change 1 to 4, 2 to 3, 3 to 2, and 4 to 1. If there are an odd number of response options, the middle in the sequence will be unchanged.

Usage

reverse(x, mini, maxi)

Arguments

x

numeric vector.

mini

numeric vector of length 1 specifying the minimum numeric value.

maxi

numeric vector of length 1 specifying the maximum numeric value.

Value

numeric vector that correlates exactly -1 with x.

See Also

reverses reverse.code recode

Examples

x <- psych::bfi[[1]]
head(x, n = 15)
y <- reverse(x = psych::bfi[[1]], min = 1, max = 6)
head(y, n = 15)
cor(x, y, use = "complete.obs")

[Package quest version 0.2.0 Index]