From 9f9339d77b5221153e543301d7350e04ce6ba27c Mon Sep 17 00:00:00 2001 From: thierrychambert <thierry.chambert@gmail.com> Date: Fri, 13 Aug 2021 17:08:57 +0200 Subject: [PATCH] Cleaned "param" reactive values and thier use in run_simul This version of the Shiny App works great ! --- inst/ShinyApp/runApp.R | 1 - inst/ShinyApp/server.R | 64 +++++++++++++++++++++++++++++++----------- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/inst/ShinyApp/runApp.R b/inst/ShinyApp/runApp.R index 01caab2..266fa21 100644 --- a/inst/ShinyApp/runApp.R +++ b/inst/ShinyApp/runApp.R @@ -1,4 +1,3 @@ -library(eolpop) source("./inst/ShinyApp/ui.R") source("./inst/ShinyApp/server.R") diff --git a/inst/ShinyApp/server.R b/inst/ShinyApp/server.R index 981b865..6e8697a 100644 --- a/inst/ShinyApp/server.R +++ b/inst/ShinyApp/server.R @@ -134,30 +134,62 @@ server <- function(input, output, session){ ## Reactive value : simulation inputs -- ##-------------------------------------------- param <- reactiveValues(N1 = NULL, + nsim = NULL, + cumulated_impacts = NULL, + fatalities_mean = NULL, + fatalities_se = NULL, + onset_time = NULL, + onset_year = NULL, + + pop_size_mean = NULL, + pop_size_se = NULL, + pop_size_type = NULL, + + pop_growth_mean = NULL, + pop_growth_se = NULL, + fecundities = NULL, survivals = NULL, s_calibrated = NULL, f_calibrated = NULL, vr_calibrated = NULL, - cumulated_impacts = NULL, - onset_time = NULL, - onset_year = NULL, + carrying_capacity = NULL, + theta = NULL, rMAX_species = NULL, - theta = theta, + + model_demo = NULL, + time_horzion = NULL, + coeff_var_environ = NULL, + fatal_constant = NULL, + fatalities_eli_result = NULL, pop_size_eli_result = NULL, - pop_size_mean = NULL, - pop_size_se = NULL, - pop_size_type = NULL, pop_growth_eli_result = NULL, - pop_growth_mean = NULL, - pop_growth_se = NULL, - carrying_cap_eli_result = NULL) + carrying_cap_eli_result = NULL + ) + ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~### + + + ##---------------------------------------------------------- + ## Observe parameter values to be used in simulations run -- + ##---------------------------------------------------------- + observe({ + param # required to ensure up-to-date values are run + + # simple inputs + param$nsim <- input$nsim + param$fatal_constant <- input$fatal_constant + + # fixed in global environment (for now) + param$theta = theta + param$time_horzion = time_horzion + param$coeff_var_environ = coeff_var_environ + + }) # end observe ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~### - observe(param) ##-------------------------------------------- ## Display parameter distribution -- @@ -451,7 +483,7 @@ server <- function(input, output, session){ withProgress(message = 'Simulation progress', value = 0, { - param$N1 <- run_simul_shiny(nsim = input$nsim, + param$N1 <- run_simul_shiny(nsim = param$nsim, cumulated_impacts = param$cumulated_impacts, fatalities_mean = param$fatalities_mean, @@ -469,13 +501,13 @@ server <- function(input, output, session){ fecundities = param$f_calibrated, carrying_capacity = param$carrying_capacity, - theta = theta, + theta = param$theta, rMAX_species = param$rMAX_species, model_demo = NULL, - time_horzion = time_horzion, - coeff_var_environ = coeff_var_environ, - fatal_constant = input$fatal_constant) + time_horzion = param$time_horzion, + coeff_var_environ = param$coeff_var_environ, + fatal_constant = param$fatal_constant) }) # Close withProgress }) # Close observEvent -- GitLab