xlsx_insert_png | R Documentation |
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.
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",
...
)
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) |
List containing the result of the tryCatch used to invoke the plot prints.
[openxlsx::insertImage()]
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.