Learn R Programming

DCC (version 1.2.1)

detect_straightlining: Detect straight-lining (longstring)

Description

Computes the longest run of identical consecutive item responses per respondent (the longstring index; cf. the CRAN package careless) and flags respondents whose run meets or exceeds max_run. The computation is vectorized over respondents.

Usage

detect_straightlining(x, items, max_run = 10L, id_var = NULL,
  severity = "warn", na_breaks_run = TRUE)

Value

A dcc_findings table (check id Q_STRAIGHTLINING).

Arguments

x

A dcc_data object or data.frame.

items

Character vector of item column names, in presentation order.

max_run

Minimum run length considered straight-lining (default 10).

id_var

Name of the record-id column, or NULL for row numbers.

severity

Severity assigned to findings (default "warn").

na_breaks_run

Should a missing response break a run? (default TRUE).

Examples

Run this code
df <- data.frame(sid = c("S1", "S2"),
                 q1 = c(1, 4), q2 = c(2, 4), q3 = c(1, 4), q4 = c(3, 4))
detect_straightlining(df, paste0("q", 1:4), max_run = 4, id_var = "sid")

Run the code above in your browser using DataLab