I've created a table with a search bar that allows me to query the data and it shows only the rows that meet a criteria. I've also created a download button that will allow me to download the table as a csv file. Right now, I can only download the entire data table. Is there a way to make the output of the download button show only the records that I've queried using the search bar? Below are the sections from my server and ui:
# create an output table of this dataframe (Full table on tab)
output$table <- DT::renderDataTable({
DT::datatable(SSdat[[1]])
# search box:
output$table <- DT::renderDataTable(
DT::datatable(SSdat[[1]], options = list(searching = TRUE))
)
})
# Downloadable csv of selected dataset ----
output$downloadData <- downloadHandler(
filename = function() {
paste("ApiaryDataSubset",rad,"miles", ".csv", sep = "")
},
content = function(file) {
write.csv(SSdat[[1]], file)
}
)
# creating an ouput for the table
tabPanel("Table",
DT::dataTableOutput("table"),
# Button
downloadButton("downloadData", "Download")
),