I have been trying to download the plotout while using eventReactive in R shiny. Below is the example code
library(shiny)
server <- function(input, output) {
getplot = eventReactive(input$plot,{
plot(iris[,1])
})
output$plot = renderPlot({
getplot()
})
output$downloadplot <- downloadHandler(filename ="test.png",
content = function(file) {
png(file)
getplot()
dev.off()
},
contentType = "image/png")
}
ui <- fluidPage(
actionButton("plot","test plot"),
plotOutput("plot"),
downloadButton("downloadplot", label = "Save png")
)
shinyApp(ui = ui, server = server)
Can any one help what must be changed inorder to successfuly download the file? ( currently it says file not found) p.s: I have tried using thecouter as mentioned in this R Shiny eventReactive actionBotton interaction still no success