reverse_score {petersenlab} | R Documentation |
Reverse Score Variables.
Description
Reverse score variables using either the theoretical min and max, or the observed max.
Usage
reverse_score(
data,
variables,
theoretical_max = NULL,
theoretical_min = NULL,
append_string = NULL
)
Arguments
data |
Data object. |
variables |
Names of variables to reverse score. |
theoretical_max |
(Optional): the theoretical maximum score. |
theoretical_min |
(Optional): the theoretical minimum score. |
append_string |
(Optional): a string to append to each variable name. |
Details
Reverse scores variables using either the theoretical min and max (by subtracting the theoretical maximum from each score and adding the theoretical minimum to each score) or by subtracting each score from the maximum score for that variable.
Value
Dataframe with reverse-scored variables.
Examples
mydata <- data.frame(
var1 = c(1, 2, NA, 4, 5),
var2 = c(NA, 4, 3, 2, 1)
)
variables_to_reverse_score <- c("var1", "var2")
reverse_score(
mydata,
variables = variables_to_reverse_score)
reverse_score(
mydata,
variables = variables_to_reverse_score,
append_string = ".R")
reverse_score(
mydata,
variables = variables_to_reverse_score,
theoretical_max = 7)
reverse_score(
mydata,
variables = variables_to_reverse_score,
theoretical_max = 7,
theoretical_min = 1)
[Package petersenlab version 1.0.0 Index]