shiny (version 0.9.1)

downloadHandler: File Downloads

Description

Allows content from the Shiny application to be made available to the user as file downloads (for example, downloading the currently visible data as a CSV file). Both filename and contents can be calculated dynamically at the time the user initiates the download. Assign the return value to a slot on output in your server function, and in the UI use downloadButton or downloadLink to make the download available.

Usage

downloadHandler(filename, content, contentType = NA)

Arguments

Examples

Run this code
# In server.R:
output$downloadData <- downloadHandler(
  filename = function() {
    paste('data-', Sys.Date(), '.csv', sep='')
  },
  content = function(file) {
    write.csv(data, file)
  }
)

# In ui.R:
downloadLink('downloadData', 'Download')

Run the code above in your browser using DataCamp Workspace