powered by
Compares responses on designated trap (attention-check) items with their expected values and flags respondents failing at least max_failed traps. Trap definitions are typically maintained in an external, versioned key file.
max_failed
detect_trap_items(x, traps, max_failed = 1L, id_var = NULL, severity = "fail", na_fails = TRUE)
A dcc_findings table (check id Q_TRAP_ITEMS).
dcc_findings
Q_TRAP_ITEMS
A dcc_data object or data.frame.
dcc_data
Named list or named vector: names are trap item columns, values the expected response.
Number of failed traps that triggers a finding (default 1).
Name of the record-id column, or NULL for row numbers.
NULL
Severity assigned to findings (default "fail").
"fail"
Should a missing response on a trap item count as a failure? (default TRUE).
TRUE
df <- data.frame(sid = c("S1", "S2"), trap1 = c(3, 5)) detect_trap_items(df, traps = list(trap1 = 3), id_var = "sid")
Run the code above in your browser using DataLab