ggDownload: Download a 'ggplot' object as an image file.

Description Usage Arguments Value Examples

View source: R/ggDownload.R

Description

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.

Usage

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
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()
    })
  }
)

## End(Not run)

statistikat/codeModules documentation built on Feb. 17, 2021, 11:42 a.m.