library(shiny)
library(shinyjs)
library(shinydlplot)
library(ggplot2)
ui <- fluidPage(
useShinyjs(),
downloadablePlotUI(id = 'iris_plot')
)
server <- function(input, output, session) {
plot <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point()
callModule(downloadablePlot,
id = 'iris_plot',
plot = plot,
filename = 'iris.csv',
content = function(file) {write.csv(iris, file)})
}
if (FALSE) shinyApp(ui, server)
Run the code above in your browser using DataLab