#' Say what this function does in one line
#'
#' Say what this function does in greater detail if that helps.
#' @param plot_object is a ggplot object
#' @param file_name the name of the output file for your plot
#' @param caption boolean indicating whether to include filename in caption
#' @param color of file name that will appear in caption (default is "lightgray")
#' @param face font face of caption with file name (default is "italic")
#' @param size font size of caption with file name (default is 3)
#' @param ... additional arguments for ggsave such as height, width, units, etc.
#' @keywords organization efficiency
#' @export
#' @examples
#' my_ggsave(p, "myplot.png")
my_ggsave <- function(plot_object, file_name, caption=TRUE, color = "lightgray", face = "italic", size = 3, ...){
if (caption) {
plot_object +
ggplot2::labs(caption = file_name) +
ggplot2::theme(
plot.caption = element_text(color = color, face = face, size = size)
)
} else {plot_object}
ggsave(file_name, ...)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.