View source: R/score_lurn_si_10.R
score_lurn_si_10 | R Documentation |
This function returns takes a dataframe, extracts the LURN SI-10 items, calculates the LURN SI-10 score, and returns the score along with any other requested variables from the input.
score_lurn_si_10(
input,
transfer_vars = names(input),
warn_or_stop = c("stop", "warn")
)
input |
A dataframe containing LURN SI-10 items. Other columns may also be present and will be returned by the function (if desired). The items of the SI-10 must use the recommended names: SI10_Q1-SI10_Q10. The input cannot contain any variable names that need to be returned as part of the scoring: lurn_si_10_score, lurn_si_10_count_valid, or lurn_si_10_note. Any character data will be coerced to numeric (e.g., "1" will be coerced to 1). Although it is not scored, the bother items should be named SI10_BOTHER and coded 0, 1, 2, 3. If "warn_or_stop" is set to "warn", the function will attempt to automatically re-code factors to numeric type as well, but we recommend using numeric data for the LURN SI-10. |
transfer_vars |
A vector of variable names to be found in input. These variables will be returned in the output along with the LURN SI-10 scores. |
warn_or_stop |
This is set to "stop" by default, which means that any problems in the input will cause execution of the function to stop (i.e., you will receive an error). Problems in the input include any out-of-range or non-numeric data in the input. If you receive an error message, you will need to fix your input in order to proceed. If warn_or_stop is set to "warn", then warnings will notify you that non-numeric or out-of-range data are present, which are then recoded to NA with a warning message. |
If only a subset of variables are desired to be returned, the column names can be specified in transfer_vars. It should be noted that if any out-of-range or non-numeric (e.g., character) values are detected, then execution of the function will stop by default. You can set warn_or_stop to "warn" (see below), in which case any out-of-range values or non-numeric values are re-coded to NA, and a warning will be displayed. We strongly recommend that you pre-process your data so that all values are in-range so that execution can proceed normally and no warnings are needed.
A dataframe of output containing LURN SI-10 scores, a count of valid items, and a scoring note. Any variables requested in transfer_vars will also be returned.
Items 1-8 are coded with 0-4; Items 9, 10 are coded with 0-3; the bother question is coded with 0-3. This coding must be respected. You can check the numbering on the official versions on the questionnaires found at https://nih-lurn.org/Resources/Questionnaires. A check on your input will be conducted when you score your data. If your data appear to be mis-coded, you will receive a friendly message encouraging you to carefully check your input.
We recommend that numeric type be used for the LURN SI-10 data. If you use factors, then the function will stop with an error message. If you set "warn_or_stop" to "warn", the function will attempt to fix up your data and present a warning.
We recommend using long data for longitudinal datasets for scoring LURN SI data (i.e., one row per time point).
For a list of recommended variable names for the LURN SI-10,
you can use this helper function: lurn_si_10_names()
## Not run:
score_lurn_si_10(input = lurn_si_10_test_data)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.