Render and save a table in png or pdf format

stable_save_image(
  x,
  file = attr(x, "stable_file"),
  stem = NULL,
  format = c("png", "pdf"),
  dir = getOption("pmtables.dir"),
  build_dir = tempdir(),
  ...
)

Arguments

x

an stable object.

file

the final output file name; if file has .tex extension, the extension will be replaced with the value in format; if provided as a complete path, directory information will be used as dir (see below).

stem

used to form the final output file name; this argument will override what is provided in file.

format

the output file format.

dir

the final output directory; will be overridden if file is given as a complete path.

build_dir

the directory where the image will be built.

...

passed to st_aspdf() or st_aspng(), depending on the value of format.

Details

There is considerable flexibility for specifying the output file name. This flexibility is provided to accommodate several potential different anticipated workflows.

  • file can be obtained from the stable_file attribute on x; this attribute is set when the user specifies the output file name via st_files(); if a .tex extension is found on file, it will be changed to the value found in format; in this case, file is not expected to contain the full path and the output directory can be specified by dir

  • file can be passed by the user; in this case, a complete path can be provided to the output file; this path will override what is in dir and a warning is given in case path location is found in both sources; if a .tex extension is found on file, it will be changed to the value found in format

  • stem and format can be passed and the output file name will be <dir>/<stem>.<format>

See also

Examples

tab <- stable(stdata(), output_file = "foo.tex")

if (FALSE) { # \dontrun{
  ans <- stable_save_image(tab, format = "pdf")
  basename(ans)
  st_image_show(ans)
} # }