Skip to content

Commit

Permalink
add region to the data, display the summary and remove ggplotTabl ref…
Browse files Browse the repository at this point in the history
…erences
  • Loading branch information
MeWu-IDM committed Apr 12, 2024
1 parent a676950 commit f39e452
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 43 deletions.
68 changes: 34 additions & 34 deletions R/ggplotTab.R → R/archive/ggplotTab.R
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
library(shiny)



ggplotTabUI <- function(id=NULL, title=NULL) {
#namespace ns
#wrap input and output ids with ns
ns <- NS(id)

tabPanel(title,
fluidRow(
style = "margin: 0 5px;",
plotOutput(ns("plot")),
div(class="visual-placeholder-xl")
))
}


ggplotTabServer <- function(id, plotting_function, rv) {
moduleServer(id, function(input, output, session) {
output$plot <- renderPlot({

if (!is.null(rv$results) ) {
plot <- do.call(plotting_function, list(rv))
plot
}else{
print("no results")
NULL
}
})
})
}


library(shiny)



ggplotTabUI <- function(id=NULL, title=NULL) {
#namespace ns
#wrap input and output ids with ns
ns <- NS(id)

tabPanel(title,
fluidRow(
style = "margin: 0 5px;",
plotOutput(ns("plot")),
div(class="visual-placeholder-xl")
))
}


ggplotTabServer <- function(id, plotting_function, rv) {
moduleServer(id, function(input, output, session) {
output$plot <- renderPlot({

if (!is.null(rv$results) ) {
plot <- do.call(plotting_function, list(rv))
plot
}else{
print("no results")
NULL
}
})
})
}


16 changes: 8 additions & 8 deletions R/simulationFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,35 @@ run_pacehrh_simulation <- function(rv, input_file){

new_rv$Mean_ServiceCat <- SS$Mean_ServiceCat %>%
inner_join(e$scenarios, by= c("Scenario_ID" = "UniqueID")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

new_rv$Mean_MonthlyTask <- SS$Mean_AnnualTask %>%
inner_join(e$scenarios, by=c("Scenario_ID" = "UniqueID")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

new_rv$Stats_TotClin <- SS$Stats_TotClin %>%
inner_join(e$scenarios, by= c("Scenario_ID"="UniqueID", "WeeksPerYr", "HrsPerWeek")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

new_rv$Mean_ClinCat <- SS$Mean_ClinCat %>%
inner_join(e$scenarios, by=c("Scenario_ID"="UniqueID", "WeeksPerYr")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

new_rv$Mean_Total <- SS$Mean_Total %>%
inner_join(e$scenarios, by= c("Scenario_ID"="UniqueID", "WeeksPerYr", "HrsPerWeek")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

new_rv$Stats_ClinMonth <- SS$Stats_ClinMonth %>%
inner_join(e$scenarios, by= c("Scenario_ID"="UniqueID", "WeeksPerYr", "HrsPerWeek")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

new_rv$ByRun_ClinMonth <- SS$ByRun_ClinMonth %>%
inner_join(e$scenarios, by= c("Scenario_ID"="UniqueID", "WeeksPerYr", "HrsPerWeek")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

new_rv$Mean_Alloc <- SS$Mean_Alloc %>%
inner_join(e$scenarios, by= c("Scenario_ID"="UniqueID", "WeeksPerYr")) %>%
mutate(test_name = rv$run_name)
mutate(test_name = rv$run_name, region=rv$region)

loggerServer("logger", paste0("Saving Mean_ServiceCat to : ", file.path(results_dir, "Mean_ServiceCat.csv")))
write.csv(new_rv$Mean_ServiceCat,file.path(results_dir, "Mean_ServiceCat.csv"), row.names = FALSE)
Expand Down
14 changes: 13 additions & 1 deletion R/view_runs.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,22 @@ viewRunsServer <- function(id, rv, store) {
# ))
# })

read_info <- function(name) {
file_path <- file.path(result_root, name, "info.txt")
if (file.exists(file_path)) {
return(readLines(file_path))
} else {
return("Info Missing")
}
}

observeEvent(input$test_history, {
df_history <- jsonlite::fromJSON(input$test_history)
df_history$summary <- apply(df_history, 1, function(row) {
read_info(row["name"])
})
df_history$datetime <- as.POSIXct(df_history$date, format = "%m/%d/%Y, %I:%M:%S %p", tz = "UTC")
rv$df_history <- df_history%>% arrange(desc(datetime)) %>% select(-(datetime))
rv$df_history <- df_history%>% arrange(desc(datetime)) %>% select(-(datetime), -(catchment_pop), -(hrs_per_wk), -(max_utilization))
selectedRows(c(TRUE, rep(FALSE, nrow(rv$df_history)-1)))
output$history_table <- renderDT({
checkboxData <- transform(rv$df_history, Select = sprintf('<input type="checkbox" name="row_selected" %s/>', ifelse(selectedRows(), "checked", "")))
Expand Down

0 comments on commit f39e452

Please sign in to comment.