Skip to contents

Saves the table code produced by tabulergm and copies the generated term figures out of the temporary cache into a user-controlled directory. The exported table references the copied image files with relative paths, making the result easier to reuse in another document or project.

Usage

tabulergm_save(object, path, ...)

# S3 method for class 'ergm'
tabulergm_save(
  object,
  path,
  format = c("markdown", "latex"),
  filename = "tabulergm-table",
  images_dir = "figures",
  overwrite = TRUE,
  latex_image_width = "0.7in",
  ...
)

# S3 method for class 'formula'
tabulergm_save(
  object,
  path,
  format = c("markdown", "latex"),
  filename = "tabulergm-table",
  images_dir = "figures",
  overwrite = TRUE,
  latex_image_width = "0.7in",
  ...
)

# S3 method for class 'data.frame'
tabulergm_save(
  object,
  path,
  format = c("markdown", "latex"),
  filename = "tabulergm-table",
  images_dir = "figures",
  overwrite = TRUE,
  latex_image_width = "0.7in",
  ...
)

Arguments

object

A fitted ergm object, an ERGM formula, or a data.frame returned by tabulergm_table().

path

Target directory. It is created recursively when needed.

...

For ergm and formula methods, additional arguments passed to tabulergm_table(). For the data.frame method, additional arguments are ignored.

format

Character vector of output formats to write. Supported values are "markdown" and "latex". By default both are written.

filename

File name stem for the table code files, without extension. Defaults to "tabulergm-table".

images_dir

Directory, relative to path, where copied images should be stored. Use "." to place images directly in path.

overwrite

Logical. Overwrite existing table code and image files? Default TRUE.

latex_image_width

Character width passed to \\includegraphics in LaTeX output. Default "0.7in".

Value

Invisibly returns a list with:

path

The normalized export directory.

files

Named character vector of written table code files.

figures

Named character vector of copied figure files, where names are the relative paths used in the table.

table

The data frame used for export, with figure paths rewritten to the copied relative paths.

Methods (by class)

  • tabulergm_save(ergm): Method for fitted ergm objects.

  • tabulergm_save(formula): Method for formula objects.

  • tabulergm_save(data.frame): Method for data frames returned by tabulergm_table().

Examples

if (requireNamespace("knitr", quietly = TRUE)) {
  fit <- readRDS(system.file("fits", "fit_edges.rds", package = "tabulergm"))
  out_dir <- tempfile("tabulergm-export-")
  tabulergm_save(fit, out_dir, include_math = TRUE)
}
#> Warning: This object was fit with ‘ergm’ version 4.9.0 or earlier. Summarizing it with version 4.10 or later may return incorrect results or fail.