Downloading Data description

I think this page could be more helpful for a beginner like me; https://shiny.rstudio.com/articles/download.html

I don't understand this concept enough to make sense of it, but I wish the statement below would explain by example more than by pointing out a case that doesn't work (I can do that :wink: ). What about a case that does work?

"Both the filename and content arguments can use reactive values and expressions (although in the case of filename , if you are using a reactive value, be sure your argument is an actual function; filename = paste(input$dataset, ".csv", sep = "") will not work the way you want it to, since it is evaluated only once, when the download handler is being defined)."

Many of these articles do assume familiarity with the mechanics of how shiny works, that is, basics of R, R-function arguments, reactivity, and so on. So I can see how this would be confusing when you're just getting started with these concepts.

If that is the case, the Shiny team created a three-hour intro course on Shiny here: https://shiny.rstudio.com/tutorial/, which is a great place to start. I feel this (with an intro to R, of course), will help make these docs much more useful.

Also, note that all this is documentation for a free and open source tool, so the shiny community is quite welcome to your ideas to improve this documentation.


To answer your question, what should this look like? the article gives an example of what this should look like in the code block reproduced below;

  # Downloadable csv of selected dataset ----
  output$downloadData <- downloadHandler(
    filename = function() {
      paste(input$dataset, ".csv", sep = "")
    },
    content = function(file) {
      write.csv(datasetInput(), file, row.names = FALSE)
    }
  )

Note that rpaste(input$dataset, ".csv", sep = "") was placed into a function function(){...}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.