Downloading png from Shiny (R)

后端 未结 1 699
面向向阳花
面向向阳花 2020-12-01 14:10

I am pretty new to Shiny (and R) and struggling with exporting the plot I make in Shiny to a png-file.

I looked at these two threads but could not figure it out:

相关标签:
1条回答
  • 2020-12-01 15:16

    A workaround for this strange scenario was discussed on the shiny-discuss google group. What you can do is simply change your reactive plotInput statement into a normal function. Not sure why downloadHandler doesn't play nice with reactive objects.

    # change
    plotInput <- reactive({...})
    
    # into this
    plotInput <- function(){...}
    

    You can also remove the print statement in the downloadHandler call:

    output$downloadPlot <- downloadHandler(
          filename = "Shinyplot.png",
          content = function(file) {
            png(file)
            plotInput()
            dev.off()
          })    
    
    0 讨论(0)
提交回复
热议问题