output_plots: Output plots with specified format and checking for existing...

View source: R/output_plots.R

output_plotsR Documentation

Output plots with specified format and checking for existing file

Description

This function outputs plots with a specified format, while allowing checks for whether to overwrite an existing file. It is basically a wrapper on pdf, png, and plotscale::as.pdf.

Usage

output_plots(
  x,
  fileDir = "plots",
  fileStem,
  plotFormat = c("plotscalePdf", "pdf", "png"),
  width,
  height,
  pngRes = 150,
  overwrite = FALSE
)

outputPlots(
  x,
  fileDir = "plots",
  fileStem,
  plotFormat = c("plotscalePdf", "pdf", "png"),
  width,
  height,
  pngRes = 150,
  overwrite = FALSE
)

Arguments

x

plot object

fileDir

directory to save the file. Defaults to "plots", which outputs to a subfolder in the working directory. If the specified directory does not exist, the function will create it.

fileStem

the stem of the file name, without the extension

plotFormat

character vector of plot formats to output. Can be any combination of "plotscalePdf", "pdf", and "png".

width

width of the plot or graphics output in inches; for plotscalePdf, this is the width of the plot area, not the graphics output area

height

height of the plot or graphics output; for plotscalePdf, this is the width of the plot area, not the graphics output area

pngRes

resolution of the PNG file in dpi. Ignored if "png" is not in plotFormat. Defaults to 150.

overwrite

logical indicating whether to overwrite an existing file. Defaults to FALSE. If FALSE and the file exists, the function will output a warning.


BenaroyaResearch/miscHelpers documentation built on April 13, 2025, 9:52 p.m.