score_subtraction {lwc2022} | R Documentation |
Score Serial Subtraction Task
Description
This function scores a serial subtraction task where respondents are scored based on their ability to successfully subtract a specific value (e.g., 7) from the previous value. A score of 1 is given for correct subtraction, and a score of 0 is given for incorrect subtraction. However, a respondent can still receive a score of 1 if they recover from an initial mistake by correctly subtracting later.
Usage
score_subtraction(val, diff)
Arguments
val |
A numeric vector representing the respondent's current answer. |
diff |
A numeric vector representing the correct difference (e.g., expected subtraction value). |
Details
The function checks if the respondent's answer (val
) is equal to the correct subtraction
difference (diff
). If so, they are awarded a score of 1. If they make a mistake, they get 0.
However, if they correct their mistake in the next step, they can receive a score of 1 for that step.
Missing values (NA) in the input remain as NA in the output.
Value
A numeric vector where:
-
1
: Correct subtraction. -
0
: Incorrect subtraction. -
NA
: If the original value is missing (NA), it remains NA.
Examples
responses <- c(93, 86, 79, 72, NA)
correct_diffs <- c(93, 86, 79, 72, 65) - 7
score_subtraction(responses, correct_diffs)