latexify_report: Transform text from 'report::report()' into LaTeX-friendly...

latexify_reportR Documentation

Transform text from report::report() into LaTeX-friendly output.

Description

This function transforms the text output from report::report() by performing several substitutions to prepare the text for LaTeX typesetting. In particular, it replaces instances of R2, ⁠%⁠, and ~ with the corresponding LaTeX code. Additionally, it provides options to:

  • Omit bullet items marked as "non-significant" (when only_sig = TRUE).

  • Remove a concluding note about standardized parameters (when remove_std = TRUE).

  • Wrap bullet items in a LaTeX itemize environment or leave them as plain text (controlled by itemize).

Usage

latexify_report(
  x,
  print_result = TRUE,
  only_sig = FALSE,
  remove_std = FALSE,
  itemize = TRUE
)

Arguments

x

Character vector or a single string containing the report text.

print_result

Logical. If TRUE (default), the formatted text is printed to the console.

only_sig

Logical. If TRUE, bullet items containing "non-significant" are omitted. Default is FALSE.

remove_std

Logical. If TRUE, the final standardized parameters note is removed. Default is FALSE.

itemize

Logical. If TRUE (default), bullet items are wrapped in a LaTeX itemize environment; otherwise the bullet markers are simply removed.

Value

A single string with the LaTeX-friendly formatted report text.

Examples


if (requireNamespace("report", quietly = TRUE)) {
  # Simple linear model on the iris dataset
  model <- stats::lm(
    Sepal.Length ~ Sepal.Width + Petal.Length,
    data = datasets::iris
  )

  # Format the report output, showing only significant items, removing the
  # standard note, and wrapping bullet items in an itemize environment.
  report_text <- try(report::report(model), silent = TRUE)
  if (!inherits(report_text, "try-error")) {
    latexify_report(
      report_text,
      only_sig = TRUE,
      remove_std = TRUE,
      itemize = TRUE
    )
  }
}


colleyRstats documentation built on May 3, 2026, 5:07 p.m.