output
in your server
function, and in the UI use downloadButton
or downloadLink
to make the download
available.downloadHandler(filename, content, contentType = NA)
file
that is a file path (string) of a nonexistent
temp file, and writes the content to that file path.
(Reactive values and functions may be used from this
function.)"text/csv"
or
"image/png"
. If NULL
or NA
, the
content type will be guessed base# 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 DataLab