downloadButton/ downloadHandler does not recognize filename argument

I've run into a problem with downloadHandler() in Shiny:
If I want to download any file via this function, the filename in the download window is the same as the name of the output-variable (in the example: "downloadData"), but not as it is declared in "filename=" in downloadHandler() (which should be "data-2017-02-13.csv").

Note that the following example is from the downloadHandler() - help page, so I guess there is a general problem with R or RStudio in which I write R scripts.
Additionally when I open the shiny app in a web browser, the problem vanishes.
This partially solves it, but I would still like to know why shiny is behaving differently inside RStudio and a web browser.

## Only run examples in interactive R sessions
if (interactive()) {

ui <- fluidPage(
  downloadLink("downloadData", "Download")
)

server <- function(input, output) {
  # Our dataset
  data <- mtcars

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

shinyApp(ui, server)
}

and here the download window I get: 在这里输入图像描述


当我使用RStudio预览窗口时,我遇到了同样的问题,并且始终通过使用该命令打开浏览器来解决此问题

runApp(launch.browser = TRUE)

链接地址: http://www.djcxy.com/p/95070.html

上一篇: logstash输出到elasticsearch索引和映射

下一篇: downloadButton / downloadHandler不识别文件名参数