reverse_scoring: Reverse Scoring

View source: R/reverse_scoring.R

reverse_scoringR Documentation

Reverse Scoring

Description

This function wraps dplyr::mutate() to reverse score columns given in the ... argument. This procedure is frequently used for e.g. Likert scale questions whereby different questions within the same questionnaire have positive or negative valence. Note that you can supply an arbitrary number of variables to the ... argument; this usage is recommended only if all of the variables have the same maximum value (e.g. again, a common situation for Likert questionnaires.)

Usage

reverse_scoring(.data, ..., max_score)

Arguments

.data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

...

variables to have their score reversed

max_score

maximum attainable score on the variables selected; needs to be the same maximum for all vars

Examples

data <- tibble(a = c(3,4,5,3), b=c(1,2,1,1))

data
## # A tibble: 4 × 2
##       a     b
##   <dbl> <dbl>
## 1     3     1
## 2     4     2
## 3     5     1
## 4     3     1
# Say that column a is reverse scored with a max value of 5.
data %>%
   reverse_scoring(a, max_score = 5)
## # A tibble: 4 × 2
##       a     b
##   <dbl> <dbl>
## 1     3     1
## 2     2     2
## 3     1     1
## 4     3     1

NeuroShepherd/RankinLabTools documentation built on Sept. 23, 2022, 5:31 p.m.