
Pipeline-aware data quality report for health data
Source:R/sus_data_quality_report.R
sus_data_quality_report.RdReads sus_meta processing history to identify which climasus4r pipeline
functions were applied, then produces a section-by-section quality
assessment covering completeness, demographic distributions, date
validity, ICD-10 codes, geographic coverage, and derived variables.
Returns an overall quality score (0-100) and supports four output formats.
Usage
sus_data_quality_report(
df,
output_format = "console",
output_file = NULL,
save_file = TRUE,
open_file = TRUE,
check_icd = TRUE,
check_dates = TRUE,
top_n = 10,
lang = "pt",
verbose = TRUE
)Arguments
- df
A
climasus_dfor plaindata.frame. Arrow objects are materialised automatically.- output_format
Character. One of
"console"(default),"gt","markdown", or"html". The"gt"format returns agt_tblobject suitable for Quarto / R Markdown documents.- output_file
Character. File path for
"markdown"and"html"formats. Defaults to a timestamped filename in the working directory.- save_file
Logical. For
"markdown"and"html"formats, whether to write the report to disk. DefaultTRUE. Set toFALSEto only compute and return the metrics (e.g.$score) without creating a file.- open_file
Logical. When
output_format = "html"andsave_file = TRUE, automatically open the saved report in the system's default browser (viautils::browseURL()). DefaultTRUE. Only triggers in interactive sessions.- check_icd
Logical. Include ICD-10 quality section. Default
TRUE.- check_dates
Logical. Include date validation section. Default
TRUE.- top_n
Integer. Rows shown in frequency tables. Default
10.- lang
Character. Output language:
"pt"(default),"en","es".- verbose
Logical. Print progress messages. Default
TRUE.
Value
Invisibly returns a named list of quality metrics (always
available regardless of output_format):
$metaPipeline metadata from
sus_meta$pipelineFunctions detected in processing history
$overviewRow/column counts, duplicates, column types
$missingPer-column missing values with quality flags
$demographicsFrequency tables for sex, race, age, education
$datesDate range and validity per date column
$icdICD-10 frequency and validity
$geographicMunicipality and state coverage
$derivedPresence of expected derived variables
$scoreOverall quality score 0-100
Examples
if (FALSE) { # \dontrun{
# Console report (default)
sus_data_quality_report(df, lang = "pt")
# gt table (for Quarto / R Markdown)
sus_data_quality_report(df, output_format = "gt", lang = "en")
# Save complete Markdown report
sus_data_quality_report(df, output_format = "markdown",
output_file = "reports/quality.md", lang = "pt")
# Save HTML report
sus_data_quality_report(df, output_format = "html",
output_file = "reports/quality.html")
} # }