missTally: Determine the number (or proportion) of missing (or...

View source: R/scorehelpers.R

missTallyR Documentation

Determine the number (or proportion) of missing (or non-missing) items for each respondent

Description

This is a handy helper function that can be used in PRO scoring functions to determine the number (or proportion) of item responses that are missing (or valid) for each row in a data frame of items. This is used by scoreScale to help determine if a respondent has answered enough items to be assigned a prorated scale score.

Usage

missTally(dfItems, what = c("pmiss", "nmiss", "pvalid", "nvalid"))

Arguments

dfItems

A data frame containing only the items of interest.

what

One of four quoted names indicating the value you want for each respondent (row) in dfItems: (1) "pmiss" (the default), for the proportion of items that are missing; (2) "nmiss", for the number of items that are missing; (3) "pvalid", for the proportion of items that are valid, non-missing; and (4) "nvalid" for the number of items that are valid, non-missing.

Value

A vector of length nrow(dfItems) that contains the quantity requested in what for each row of dfItems.

Examples

set.seed(8675309)
#  Make data frame with 10 respondents, 10 items, and approx 30% missing data
(myItems <- makeFakeData(n = 10, nitems = 10, propmiss = .30))
#  The default is to return "pmiss", the proportion missing for each row.
missTally(myItems)
missTally(myItems, "pvalid")
missTally(myItems, "nmiss")
missTally(myItems, "nvalid")

PROscorerTools documentation built on Oct. 17, 2023, 9:06 a.m.