Learn R Programming

misty (version 0.4.5)

item.reverse: Reverse Code Scale Item

Description

This function reverse codes an inverted item, i.e., item that is negatively worded.

Usage

item.reverse(x, min = NULL, max = NULL, keep = NULL, as.na = NULL, table = FALSE,
             check = TRUE)

Arguments

x

a numeric vector.

min

an integer indicating the minimum of the item (i.e., lowest possible scale value).

max

an integer indicating the maximum of the item (i.e., highest possible scale value).

keep

a numeric vector indicating values not to be reverse coded.

as.na

a numeric vector indicating user-defined missing values, i.e. these values are converted to NA before conducting the analysis.

table

logical: if TRUE, a cross table item x reverse coded item is printed on the console.

check

logical: if TRUE, argument specification is checked.

Value

Returns a numeric vector with the same length as x containing the reverse coded scale item.

Details

If arguments min and/or max are not specified, empirical minimum and/or maximum is computed from the vector. Note, however, that reverse coding might fail if the lowest or highest possible scale value is not represented in the vector. That is, it is always preferable to specify the arguments min and max.

References

Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. New York: John Wiley & Sons.

See Also

item.alpha, item.omega, rec, item.scores

Examples

Run this code
# NOT RUN {
dat <- data.frame(item1 = c(1, 5, 3, 1, 4, 4, 1, 5),
                  item2 = c(1, 1.3, 1.7, 2, 2.7, 3.3, 4.7, 5),
                  item3 = c(4, 2, 4, 5, 1, 3, 5, -99))

# Reverse code item1
dat$item1r <- item.reverse(dat$item1, min = 1, max = 5)

# Reverse code item2
dat$item2r <- item.reverse(dat$item2, min = 1, max = 5)

# Reverse code item3 while keeping the value -99
dat$item3r <- item.reverse(dat$item3, min = 1, max = 5, keep = -99)

# Reverse code item3 while keeping the value -99 and check recoding
dat$item3r <- item.reverse(dat$item3, min = 1, max = 5, keep = -99, table = TRUE)
# }

Run the code above in your browser using DataLab