Learn R Programming

colleyRstats (version 0.0.1)

latexify_report: 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
)

Value

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

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.

Examples

Run this code
# \donttest{
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.
  latexify_report(
    report::report(model),
    only_sig = TRUE,
    remove_std = TRUE,
    itemize = TRUE
  )
}
# }

Run the code above in your browser using DataLab