Wie kann ich den Download-Button an diesem einfachen Beispiel reparieren?Shinydashboard ausgegraut downloadButton?
library(shiny)
library(shinydashboard)
library(shinyjs)
header <- dashboardHeader()
sidebar <- dashboardSidebar(shinyjs::useShinyjs(),
actionButton("start_proc", "Click to make download button appear"),
p(),
downloadButton('data_file', 'Download'))
body <- dashboardBody()
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
observe({
if (input$start_proc > 0) {
Sys.sleep(1)
# enable the download button
shinyjs::show("data_file")
}
})
output$data_file <- downloadHandler(
filename = function() {
paste('data-', Sys.Date(), '.csv', sep='')
},
content = function(file) {
write.csv(data.frame(x=runif(5), y=rnorm(5)), file)
}
)
# disable the downdload button on page load
shinyjs::hide("data_file")
}
shinyApp(ui, server)