Create a ui that contains controls for the height and width of the plot as well as a downloadButton. The module uses ggsave to convert the plot into an image file.

ggDownload(input, output, session, plotObj, plotObjName = "ggObj")

ggDownloadUI(id, downloadText = "Download image file",
  previewText = "Open in new tab")

Arguments

input, output, session

Standard module parameters

plotObj

A reactive ggplot object

plotObjName

The name of the object in the resulting code

id

The module identifier.

downloadText

Text do display on the downloadButton.

previewText

Text to display in the preview button.

Value

A reactive string that represents the code for downloading the plot.

Examples

if (FALSE) { library(ggplot2) gg <- ggplot(mtcars, aes(wt, mpg)) + geom_point() shinyApp( fluidPage( ggDownloadUI("ggd"), codeOutput("code") ), function(input, output, session){ code <- callModule(ggDownload, "ggd", reactive({gg})) output$code <- renderCode({ code() }) } ) }