Skip to contents

Renders a report's figure and writes it via ggplot2::ggsave(). For the report as a depositable CSV instead, use write_report().

Usage

save_figure(report, filename, width = 8.5, height = NULL, dpi = 300, ...)

Arguments

report

An object of class instar_report.

filename

Output file path (extension determines format; .pdf or .png are recommended).

width

Page width in inches. Defaults to 8.5".

height

Page height in inches. If NULL (the default), a compact height is chosen from the content, clamped to [6, 11].

dpi

Resolution for raster formats. Defaults to 300.

...

Additional arguments passed to ggplot2::ggsave().

Value

The filename, invisibly.

Details

The default page height is computed from the figure's natural content size, so the saved file is as compact as the content allows with no large blank regions. Pass an explicit height to override.

Examples

if (FALSE) { # \dontrun{
rep <- instar_report(instar_template(), list(title = "T", authors = "A"))
save_figure(rep, "welfare_reporting.pdf")
} # }