Why wont the filename register that input$format has changed within the download handler? If I print the value of input$format in the UI, the value changes when I change radiobutton selections.
output$download_data <- downloadHandler(
filename = paste0("longdataset_", Sys.time(), input$format),
content = function(file){
if(input$format=='.csv'){
write.csv(data(), file, row.names=FALSE,
na='')}
if(input$format=='.xls'){
sdat <- data()
WriteXLS('sdat',
file)
}}
)
# UI
radioButtons('format', 'File type:',
choices=c('.xls',
'.csv'),
selected='.xls'),
downloadButton('download_data', 'Download long dataset')