View source: R/quest_functions.R
reverse | R Documentation |
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.
reverse(x, mini, maxi)
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. |
numeric vector that correlates exactly -1 with x
.
reverses
reverse.code
recode
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.