I have a table with 500,000 rows. I would like to be able to use the shinyapps data table to search the table, and then download the result of the search. I was able to get the download button to work, but even after using the search function to filter the data, I'm still given the full set of data when I click download. I'm reading through a few guides, including mastering shiny, but can't seem to find any tips or instructions to include this feature. Any information would be greatly appreciated.
Here's the shiny code I'm using:
ui <- fluidPage(
downloadButton("download", "Download .csv"),
align="center",
theme = shinytheme("spacelab"),
titlePanel("Data"),
fluidRow(
column(3),
column(6,
DT::dataTableOutput("df_filtered")
),
column(3)
)
)
server <- function(input, output) {
datasetInput1 <- reactive({
df_filtered
})
output$df_filtered <- renderDataTable({
dataset <- datasetInput1()
})
output$download <- downloadHandler(
filename = "report.csv",
content = function(file) {
write.csv(datasetInput1(), file)
}
)
}
shinyApp(ui = ui, server = server)