xlsx_insert_png: An attempt to improve the behaivor of openxlsx's plot...

View source: R/xlsx.R

xlsx_insert_pngR Documentation

An attempt to improve the behaivor of openxlsx's plot inserter.

Description

The functions provided by openxlsx for adding plots to xlsx files are quite nice, but they can be a little annoying. This attempt to catch some corner cases and potentially save an extra svg-version of each plot inserted.

Usage

xlsx_insert_png(
  a_plot,
  wb = NULL,
  sheet = 1,
  width = 6,
  height = 6,
  res = 90,
  plotname = "plot",
  savedir = "saved_plots",
  fancy = FALSE,
  fancy_type = "pdf",
  start_row = 1,
  start_col = 1,
  file_type = "png",
  units = "in",
  ...
)

Arguments

a_plot

The plot provided

wb

Workbook to which to write.

sheet

Name or number of the sheet to which to add the plot.

width

Plot width in the sheet.

height

Plot height in the sheet.

res

Resolution of the png image inserted into the sheet.

plotname

Prefix of the pdf file created.

savedir

Directory to which to save pdf copies of the plots.

fancy

Plot fancy plots with the xlsx file?

fancy_type

Plot publication quality images in this format.

start_row

Row on which to place the plot in the sheet.

start_col

Column on which to place the plot in the sheet.

file_type

Currently this only does pngs, but perhaps I will parameterize this.

units

Units for the png plotter.

...

Extra arguments are passed to arglist (Primarily for vennerable plots which are odd)

Value

List containing the result of the tryCatch used to invoke the plot prints.

See Also

[openxlsx::insertImage()]

Examples

 ## Not run: 
  fun_plot <- plot_pca(stuff)$plot
  df <- some_data_frame
  wb <- write_xlsx(df, excel = "funkytown.xlsx")$workbook
  try_results <- xlsx_insert_png(fun_plot, wb = wb)

## End(Not run)

elsayed-lab/hpgltools documentation built on May 9, 2024, 5:02 a.m.