How to fix download button sidebar issue in flexdashboard

后端 未结 1 1025
庸人自扰
庸人自扰 2021-02-05 23:19

I have added a download button to my flexdashboard in the sidebar panel, but it appears in the main panel when I knit the .RMD. Can you please guide me as to how I can fix it? <

1条回答
  •  长情又很酷
    2021-02-06 00:03

    Never mind, I fixed it and it was rather silly of me to have not tried it before posting the question, but if someone ever faces a similar problem, the solution is here.

    The download handler function must simply be placed in the sidebar panel as well and that does it.

    Inputs {.sidebar}
    -----------------------------------------------------------------------
    
    ### Input Filters
    
    ```{r input}
    
    ## Metric 1
    selectInput('metric',
                'Choose Metric',
                names(dataset %>% select(-default_column)),
                selected = "default_metric")
    
    ## Download Button
    downloadButton('downloadData','Download Result Set')
    
    downloadHandler(filename = function() {
         paste('resultset-', Sys.Date(), '.csv', sep='')
       },
         content = function(file) {
         write.csv(subset_dataset(), file, row.names = FALSE)
       }
    )
    

    0 讨论(0)
提交回复
热议问题