我想在按下按钮时在 R Shiny 中初始化文件的下载,并在生成文件之前进行一些检查。
我用 downloadHandler ( https://shiny.rstudio.com/gallery/file-download.html )愚弄了周围。但我想捕捉另一个按钮的事件,做一些事情并检查数据,当一切顺利时生成文件并初始化下载,而不必从 downloadHandler 按下下载按钮。
我现在已经在 downloadHandler 中实现了大多数检查,但是当某些检查没有完成时,它现在会生成一个失败的下载。我不喜欢这种行为。
output$downloadData <- downloadHandler(
filename = function() { paste("DATA_EXPORT-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
withProgress(message = 'Export data', value = 0, {
# Number of steps
n <- 3
incProgress(1/n, detail = "Pre checks and get data")
# checks if inputs for get_data are well defined
dataSet <- get_data(blabla)
incProgress(1/n, detail = "Post Proces and check")
incProgress(1/n, detail = "generate flatfile")
write.csv(dataSet, file, row.names …
Run Code Online (Sandbox Code Playgroud)