How to use the download button in Shiny?

此生再无相见时 提交于 2019-12-06 07:04:37

I think the problem with your code is that you are trying to download two CSV's from one downloadbutton. You have two variables called csv_write, and two write.csv calls. A minimal working example would look like:

library(shiny)

server <- shinyServer(function(input, output, session) {

  output$downloadData <- downloadHandler(
    filename = function() { 
      paste("dataset-", Sys.Date(), ".csv", sep="")
    },
    content = function(file) {
      write.csv(mtcars, file)
    })
})

ui <- shinyUI(fluidPage(
    downloadButton('downloadData', 'Download data')
))

shinyApp(ui=ui,server=server)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!