I can't seem to get my download handler to work. My table is displaying the contents of two different tables in a database based on the input selected by the user. I'm very new to shiny and R and I'm not sure if I'm doing this right or how to fix this so you can actually download the contents of the table.
tabPanel(
"Study Results",
br(),
selectInput("resultsDisplay", "Display results by", choices = c("Single Study", "Compare Studies")),
uiOutput("resultsPnoDropUI"),
selectInput("resultsType", "Results Type", choices = c("results_mn", "results_pairwise")),
downloadLink("downloadResults", "Download this File"),
br(),
br(),
DT::dataTableOutput("studyResultsTable")
)
)
})
#Database Connections and reading tables
protocolDB <-dbConnect(RSQLite::SQLite(), "clin_oral.db")
resultsDB <- dbConnect(RSQLite::SQLite(), "OralCareResults.sqlite")
results_mn <- dbReadTable(resultsDB, "Means")
pairTable <- dbReadTable(resultsDB, "Pairwise")
#Results DT Output
output$studyResultsTable = DT::renderDataTable({
resultTable <-dat<- get(input$resultsType)
})
#Download Results Table
output$downloadResults <-downloadHandler(
filename = function(){
paste("study_results_download_", Sys.Date(), ".csv", sep="")
},
content = function(file){
write.csv(resultTable, file)
}
)