reverses: Reverse Code Numeric Data

Description Usage Arguments Details Value See Also Examples

View source: R/quest_functions.R

Description

reverses reverse codes numeric data 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
reverses(data, vrb.nm, mini, maxi, suffix = "_r")

Arguments

data

data.frame of data.

vrb.nm

character vector of colnames from data specifying the variables.

mini

numeric vector of length 1 specifying the minimum numeric value.

maxi

numeric vector of length 1 specifying the maximum numeric value.

suffix

character vector of length 1 specifying the string to add to the end of the colnames in the return object.

Details

reverses is simply a vectorized version of reverse to more easily reverse code multiple columns of a data.frame at the same time.

Value

data.frame of reverse coded variables with colnames specified by paste0(vrb.nm, suffix).

See Also

reverse reverse.code recodes

Examples

1
2
3
tmp <- !(is.element(el = names(psych::bfi) , set = c("gender","education","age")))
vrb_nm <- names(psych::bfi)[tmp]
reverses(data = psych::bfi, vrb.nm = vrb_nm, mini = 1, maxi = 6)

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

Related to reverses in quest...