reverse: Reverse Code a Numeric Vector

Description Usage Arguments Value See Also Examples

View source: R/quest_functions.R

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

1
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

1
2
3
4
5
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")

quest documentation built on Sept. 10, 2021, 5:07 p.m.

Related to reverse in quest...