missTally {PROscorerTools}R 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")

[Package PROscorerTools version 0.0.4 Index]