imed_export_figure: Export a publication figure

View source: R/figures.R

imed_export_figureR Documentation

Export a publication figure

Description

Export a publication figure

Usage

imed_export_figure(
  plot,
  filename,
  width = 180,
  height = 120,
  units = "mm",
  dpi = 600
)

Arguments

plot

A 'ggplot' object, for example from 'imed_plot()'.

filename

Output file path; the format follows the file extension.

width

Figure width in 'units' (default 180).

height

Figure height in 'units' (default 120).

units

Units for 'width' and 'height' (default '"mm"').

dpi

Resolution in dots per inch (default 600).

Value

The path 'filename', returned invisibly. The function is called for its side effect of writing the figure to disk.

Examples

toy <- data.frame(
  Study_ID = paste0("S", 1:12),
  Comparability_Class = "CLASS_A",
  Reported_Unit = "items/L",
  Metric_Type = "Abundance",
  Strict_Synthesis_Eligibility = "YES",
  Group = rep(c("g1", "g2"), 6),
  Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2),
  SD = rep(c(0.6, 0.9), 6),
  N = rep(c(10, 12, 8), 4)
)
p <- imed_plot(toy, type = "histogram")
out <- tempfile(fileext = ".png")
imed_export_figure(p, out, width = 90, height = 60, dpi = 100)
file.exists(out)
unlink(out)

imedR documentation built on Nov. 3, 2026, 5:08 p.m.