generate_report: Generate an HTML or PDF Report for a Fitted Distribution

View source: R/report.R

generate_reportR Documentation

Generate an HTML or PDF Report for a Fitted Distribution

Description

Produces a standalone, self-contained HTML (or PDF) report that documents the fitted distribution, estimated parameters, goodness-of-fit tests, descriptive statistics, diagnostic plots, and (optionally) bootstrap confidence intervals.

If rmarkdown is installed, the report is rendered from an R Markdown template. Otherwise, a pure HTML fallback is used with the diagnostic plot embedded as a base64-encoded PNG image.

Usage

generate_report(fit,
                output_file = NULL,
                file        = NULL,
                title       = "FitVerse: Distribution Fitting Report",
                author      = "",
                boot        = NULL,
                top_n       = 5L,
                open        = TRUE)

Arguments

fit

An object of class "fitverse" as returned by fitverse().

output_file

Character: path to the output file. If NULL (default), a temporary file is used: fitverse_report_<dist>_<timestamp>.html.

file

Deprecated alias for output_file. Provided for backward compatibility; output_file takes precedence if both are given.

title

Character: report title. Defaults to "FitVerse: Distribution Fitting Report".

author

Character: author name to include in the report header. Default "" (no author line).

boot

An object of class "fitverse_bootstrap" (from bootstrap_ci()), or NULL. If supplied, a confidence-interval table is included in the report.

top_n

Integer: number of distributions to show in the ranking table. Default 3.

open

Logical: open the report in the system's default browser after writing? Default TRUE. Set to FALSE in automated pipelines or when running inside shiny.

Details

R Markdown path (recommended)

When rmarkdown is available, generate_report() writes a temporary .Rmd file and calls rmarkdown::render() to produce a self-contained HTML document using the html_document format with self_contained = TRUE. The fitted object is passed via a temporary .rds file to avoid workspace pollution.

HTML fallback path

When rmarkdown is unavailable, a self-contained HTML file is built in pure R:

  • The diagnostic plot is saved to a temporary PNG and encoded as a base64 data URI using base64enc (if available) or a manual hex-to-base64 conversion.

  • Tables are rendered as HTML <table> elements.

  • The output is a single-file HTML document with embedded CSS.

Value

Invisibly returns the normalised path to the output file (character).

Author(s)

Karuna G. Reddy karuna.reddy@auckland.ac.nz
M. G. M. Khan mgm.khan@usp.ac.fj

See Also

bootstrap_ci for confidence intervals to include in the report.
save_plot to save the diagnostic plot separately.

Examples


set.seed(42)
x <- rgamma(300, shape = 2, rate = 0.5)
fit <- fitverse(x, xlab = "Waiting time (s)", plot = FALSE, verbose = FALSE)

# Write report to a temporary directory so no files are left in the working dir
path <- generate_report(fit,
                        title       = "Gamma Fit Example",
                        author      = "Karuna Reddy",
                        output_file = file.path(tempdir(), "fitverse_report.html"),
                        open        = FALSE)
message("Report saved to: ", path)


FitVerse documentation built on Dec. 1, 2026, 1:07 a.m.