DownloadButton / downloadHandler does not recognize file name argument

I had a problem with downloadHandler() in Shiny:
If I want to download any file using this function, the file name in the download window will be the same as the name of the output variable (in the example: "downloadData"), but not as indicated in "filename =" in downloadHandler () (which should be "data-2017-02-13.csv").

Note that the following example is on the Handler () - help download page, so I assume there is a general problem with R or RStudio in which I write R. scripts
Also, when I open a brilliant application in a web browser, the problem disappears. This partially solves, but I still would like to know why the gloss behaves differently inside RStudio and the 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 is the download window that I get: enter image description here

+5
source share
1 answer

I had the same problem when I used the RStudio preview window and was able to solve this problem by always opening the browser with the command

runApp(launch.browser = TRUE)

+3
source

Source: https://habr.com/ru/post/1264167/


All Articles