chk_nitems {PROscorerTools}R Documentation

Checks the number and values of items passed to custom scoring functions

Description

These functions are designed to used within custom scoring functions to help check the arguments passed to those functions. Typically, these argument checkers will be used within the body of a custom scoring function before calling the scoreScale function to handle the bulk of the work. See Details.

Usage

chk_nitems(dfItems, nitems)

chkstop_nitems(dfItems, nitems)

chk_values(dfItems, values)

chkstop_values(dfItems, values)

Arguments

dfItems

A data frame with only the items to be scored.

nitems

The number of items on the scale to be scored.

values

A vector of all of the possible values that the items can take.

Details

Functions with prefix chk_ simply check whether their argument values meet a condition and return TRUE or FALSE. Functions with the prefix chkstop_ check the arguments and, if FALSE, stop execution and display an error message to help the user pinpoint the problem.

The scoreScale function is a general, all-purpose tool that can be used to score a scale regardless of the number or values of items on the scale. Because of this, however, it does not check that the user has given it the correct number of items, and it does not check that those item values are all within the range possible for that scale. Therefore, whenever scoreScale is used to write a function to score a specific instrument (presumably with a known number of items and item values), the programmer should run some additional checks on the arguments that are not already built-in to scoreScale.

Value

Functions with prefix chk_ return TRUE if the arguments pass the argument checks, or FALSE if the arguments fail the checks. Functions with the prefix chkstop_ print an error message and stop the execution of the function in which they are embedded.

Note

Use with caution! These functions work, but they might be deprecated in future updates of the package. I am hoping to come up with a more streamlined, user-friendly system for checking arguments and input values. Until then, these functions get the job done, but not as gracefully as I would like.

Examples

itemBad <- c(0, 1, 2, 3, 10)
itemGood <- c(0, 1, 2, 3, 0)
dfBad <- data.frame(itemBad, itemGood)
dfGood <- data.frame(itemGood, itemGood)
chk_nitems(dfBad, 1)
chk_nitems(dfGood, 2)
chk_values(dfBad, 0:3)
chk_values(dfGood, 0:3)


[Package PROscorerTools version 0.0.4 Index]