Evaluates collected response data against the instrument specification and produces a structured quality report. The report covers attention check performance, completion time, straight-lining within scale blocks, item-level missingness, respondent-level missingness, and duplicate respondent IDs where supplied.
Usage
quality_report(
data,
instrument,
respondent_id = NULL,
submitted_at = NULL,
started_at = NULL,
time_min = NULL,
straightline_scales = TRUE,
missing_threshold = 0.2
)Arguments
- data
A
tibbleordata.frameof responses, typically produced byread_responses().- instrument
An
sframeobject created bysf_instrument().- respondent_id
Character or NULL. The column name holding unique respondent identifiers. Used for duplicate detection.
- submitted_at
Character or NULL. The column name holding submission timestamps. Used for completion time analysis.
- started_at
Character or NULL. The column name holding survey start timestamps. When
NULL,quality_report()looks for a recognised start-time column automatically.- time_min
Numeric or NULL. Minimum acceptable completion time in seconds. Respondents with a submission time below this threshold are flagged as speeders when timing data are available.
- straightline_scales
Logical. Whether to check for straight-lining within each defined scale block. Defaults to
TRUE.- missing_threshold
Numeric. The proportion of missing item responses above which a respondent is flagged. Defaults to
0.2.
Value
An object of class sframe_quality_report, a named list with
elements: summary, attention, timing, straightline, missing,
and duplicates. Use print() for a formatted summary.
Details
Timing analysis is available when the data contain a submission timestamp
column and either an explicit started_at column or one of the recognised
defaults: started_at, start_time, started, or .started_at.
Examples
instr <- read_sframe(
system.file("extdata", "tourism_services_demo.sframe",
package = "surveyframe")
)
responses <- read_responses(
system.file("extdata", "tourism_services_responses.csv",
package = "surveyframe"),
instr,
respondent_id = "respondent_id",
submitted_at = "submitted_at",
meta_cols = "started_at"
)
qr <- quality_report(
responses,
instr,
respondent_id = "respondent_id",
submitted_at = "submitted_at",
started_at = "started_at",
straightline_scales = FALSE
)
print(qr)
#> Survey Data Quality Report
#> Respondents: 120
#> Items: 15
#> Flagged: 6 (5.0%)
#>
#> Attention checks:
#> attention_agree pass 95% fail 6
#>
#> Timing:
#> Median completion time: 966.0 seconds
#>
#> Missingness: 0.0% of respondents exceed 20% threshold