export_report: Export Comparison Report to File

View source: R/export_report.R

export_reportR Documentation

Export Comparison Report to File

Description

Exports a dataset or CDISC comparison result to a file in multiple formats. Automatically detects format from file extension (.html, .txt, .xlsx).

Usage

export_report(result, file, format = NULL)

Arguments

result

A list from compare_datasets() or cdisc_compare().

file

Character string specifying the output file path. File extension determines format: .html, .txt, or .xlsx.

format

Character string specifying output format: "html", "text", or "excel". If NULL (default), format is auto-detected from file extension.

Details

Supported formats:

  • HTML (.html): Self-contained HTML report with styling and interactive charts.

  • Text (.txt): Plain text report suitable for console review.

  • Excel (.xlsx): Multi-sheet workbook with tabbed data:

    • "Summary": Dataset dimensions, domain, standard, matching type, tolerance

    • "Variable Diffs": Metadata attribute differences

    • "Value Diffs": Unified diff data frame from get_all_differences()

    • "CDISC Validation": Combined validation results (for CDISC comparisons only)

The result object can be either a dataset_comparison (from compare_datasets()) or cdisc_comparison (from cdisc_compare()). All features are supported for both.

Value

Invisibly returns the input result (useful for piping).

Examples


# Create sample datasets
df1 <- data.frame(
  ID = c(1, 2, 3),
  NAME = c("Alice", "Bob", "Charlie"),
  AGE = c(25, 30, 35)
)

df2 <- data.frame(
  ID = c(1, 2, 3),
  NAME = c("Alice", "Bob", "Charles"),
  AGE = c(25, 30, 36)
)

# Compare datasets
result <- compare_datasets(df1, df2)

# Export to different formats (write to tempdir)
export_report(result, file.path(tempdir(), "report.html"))
export_report(result, file.path(tempdir(), "report.txt"))

# Explicit format specification
export_report(result, file.path(tempdir(), "report.xlsx"), format = "excel")


clinCompare documentation built on Feb. 19, 2026, 1:07 a.m.