% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/quality_report.R
\name{quality_report}
\alias{quality_report}
\title{Generate a data quality report for survey responses}
\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{
\item{data}{A \code{tibble} or \code{data.frame} of responses, typically produced by
\code{\link[=read_responses]{read_responses()}}.}

\item{instrument}{An \code{sframe} object created by \code{\link[=sf_instrument]{sf_instrument()}}.}

\item{respondent_id}{Character or NULL. The column name holding unique
respondent identifiers. Used for duplicate detection.}

\item{submitted_at}{Character or NULL. The column name holding submission
timestamps. Used for completion time analysis.}

\item{started_at}{Character or NULL. The column name holding survey start
timestamps. When \code{NULL}, \code{quality_report()} looks for a recognised
start-time column automatically.}

\item{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.}

\item{straightline_scales}{Logical. Whether to check for straight-lining
within each defined scale block. Defaults to \code{TRUE}.}

\item{missing_threshold}{Numeric. The proportion of missing item responses
above which a respondent is flagged. Defaults to \code{0.2}.}
}
\value{
An object of class \code{sframe_quality_report}, a named list with
elements: \code{summary}, \code{attention}, \code{timing}, \code{straightline}, \code{missing},
and \code{duplicates}. Use \code{print()} for a formatted summary.
}
\description{
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.
}
\details{
Timing analysis is available when the data contain a submission timestamp
column and either an explicit \code{started_at} column or one of the recognised
defaults: \code{started_at}, \code{start_time}, \code{started}, or \code{.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)
}
\seealso{
\code{\link[=sf_check]{sf_check()}}, \code{\link[=read_responses]{read_responses()}}, \code{\link[=score_scales]{score_scales()}}
}
