summaryTableUI <- function(id){
ns <- NS(id)
tagList(
DT::dataTableOutput(ns("table")),
downloadButton(ns("download"))
)
}
summaryTable <- function(input, output, session,
criteria, scenarios, scoring){
technical <- reactiveValues()
output$table <- DT::renderDataTable({
technical$data
},
rownames = F,
extensions = c('Responsive'),
options = list(dom = "tip")
)
observe({
req(scoring$data)
req(scenarios$data)
req(criteria$static)
if("Threshold" %in% criteria$options){
df <- criteria$static[,c("Description", "Threshold", "Weight")]
df$Threshold <- as.numeric(as.character(df$Threshold))
} else{
df <- criteria$static[,c("Description", "Weight")]
}
df$ID <- as.integer(row.names(df))
df <- scenarios$data %>%
tidyr::gather("Scenario", "Confidence", -"ID", -"Description") %>%
dplyr::select(-Description) %>%
dplyr::left_join(df, "ID") %>%
dplyr::left_join(scoring$data, by="Confidence") %>%
dplyr::mutate("Weight" = round(Weight,2)) %>%
dplyr::mutate("Weighted Score" = Weight * Score / 10)
if("Threshold" %in% criteria$options){
df <- df %>% dplyr::mutate(
"Compliant" = Score >= Threshold
)
}
technical$data <- df
})
output$download <- downloadHandler(
filename = paste0(Sys.Date(), "_Tender Evaluation Scenario Analysis_OSC.csv"),
content = function(file){
write.csv(technical$data, file, row.names=F)
}
)
return(technical)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.