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",
...
)
# S3 method for class 'tabulergm_kable'
tabulergm_save(object, path, ...)Arguments
- object
A fitted ergm object, an ERGM formula, or a table object returned by
tabulergm_table()(including a styledknitr_kable).- path
Target directory. It is created recursively when needed.
- ...
For
ergmandformulamethods, additional arguments passed totabulergm_table(). For thedata.framemethod, 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 inpath.- overwrite
Logical. Overwrite existing table code and image files? Default
TRUE.- latex_image_width
Character width passed to
\\includegraphicsin plain LaTeX output. Default"0.7in"; the compact name-over-formula style uses its fixed0.4\\linewidthlayout.
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 bytabulergm_table().tabulergm_save(tabulergm_kable): Method for formatted tables returned bytabulergm_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)
}