#' Save plot
#'
#' This will save the last ggplot call
#'
#' @param filename The file name to be written
#' @param format File extension can be "pdf", "svg", "tiff", "png", "jpg"
#' @param dingbats FALSE or TRUE (for pdf only)
#' @param h The height
#' @param w The Width
#' @param units "in", "cm"
#' @param dpi resolution for raster output types
#' @export
#' @details
#' This will save the save ggplot object that was written to the device.
#' @examples
#' save_plot(filename = "Cluster plot", format = "pdf")
save_ggplot <- function(filename = "Rplot", format = "pdf", dingbats = FALSE, dpi = 300, h = 6, w = 6, units = "in"){
if(format == "pdf"){
ggplot2::ggsave(filename = paste0(filename, ".", format), height = h, width = w, useDingbats = dingbats)
}
if(format == "png"){
ggplot2::ggsave(filename = paste0(filename, ".", format), height = h, width = w, dpi = dpi)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.