Learn R Programming

shiny (version 1.4.0.2)

downloadButton: Create a download button or link

Description

Use these functions to create a download button or link; when clicked, it will initiate a browser download. The filename and contents are specified by the corresponding downloadHandler() defined in the server function.

Usage

downloadButton(outputId, label = "Download", class = NULL, ...)

downloadLink(outputId, label = "Download", class = NULL, ...)

Arguments

outputId

The name of the output slot that the downloadHandler is assigned to.

label

The label that should appear on the button.

class

Additional CSS classes to apply to the tag, if any.

...

Other arguments to pass to the container tag function.

See Also

downloadHandler()

Examples

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

# In ui.R:
downloadLink('downloadData', 'Download')
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab