Learn R Programming

ShinyItemAnalysis (version 1.3.4)

recode_nr: Recognize and recode not-reached responses

Description

recode_nr() function recognizes and recodes not-reached responses, i.e. missing responses to items such that all subsequent items are missed as well by the respondent.

Usage

recode_nr(df, nr_code = 99)

Arguments

df

matrix or data.frame: object to be recoded, must include only items columns and no additional information

nr_code

single character, integer or numeric: specifying how should be recognized not-reached responses coded (default is 99)

Value

The same class as input object, see df.

See Also

ItemAnalysis

Examples

Run this code
# NOT RUN {
data(HCI, package = "ShinyItemAnalysis")
HCImissed <- HCI[, 1:20]

# simulate skipped (missed) and not-reached items in HCI dataset
set.seed(4211)
for (i in 1:150) {
# not-reached (minimum at 10th item, maximum at 20th)
HCImissed[sample(1:nrow(HCImissed), 1), seq(sample(10:20, 1), 20)] <- NA

# missed with random location
HCImissed[sample(1:nrow(HCImissed), 1), sample(1:20, 1)] <- NA
}

summary(HCImissed)

HCImissedNR <- recode_nr(HCImissed, nr_code = 99)
head(HCImissedNR)
summary(HCImissedNR)

# }

Run the code above in your browser using DataLab