From 45d27977f6ca77d9951ebe18bb46da766734deb3 Mon Sep 17 00:00:00 2001 From: thierrychambert <thierry.chambert@gmail.com> Date: Wed, 11 Aug 2021 17:00:57 +0200 Subject: [PATCH] Thies version of Shiny works (thierry branch) ! --- inst/ShinyApp/server.R | 11 +- inst/ShinyApp/server_old.R | 605 ------------------------------------- inst/ShinyApp/ui_old.R | 389 ------------------------ 3 files changed, 5 insertions(+), 1000 deletions(-) delete mode 100644 inst/ShinyApp/server_old.R delete mode 100644 inst/ShinyApp/ui_old.R diff --git a/inst/ShinyApp/server.R b/inst/ShinyApp/server.R index fbb0a94..0a01155 100644 --- a/inst/ShinyApp/server.R +++ b/inst/ShinyApp/server.R @@ -553,15 +553,14 @@ server <- function(input, output, session){ nrow <- input$farm_number_cumulated number_parks <- rows_names(nrow) - # data_fatalities_cumulated <- c(c(input$fatalities_mat_cumulated[,1]), - # c(input$fatalities_mat_cumulated[,2]), - # c(input$fatalities_mat_cumulated[,3])) + + init_cumul_new <- rep(init_cumul_add, nrow) updateMatrixInput(session, inputId = "fatalities_mat_cumulated", - value = matrix("", nrow = nrow, 3, + value = matrix(init_cumul_new, nrow = nrow, 3, byrow = TRUE, dimnames = list(number_parks, - c("Moyennes des mortalités annuelles", - "Ecart-type des mortalités annuelles", + c("Moyenne", + "Ecart-type", "Année de mise en service du parc")))) }) diff --git a/inst/ShinyApp/server_old.R b/inst/ShinyApp/server_old.R deleted file mode 100644 index f914e7a..0000000 --- a/inst/ShinyApp/server_old.R +++ /dev/null @@ -1,605 +0,0 @@ -server <- function(input, output, session){ - - # Hide all inputs excepted actionButtons - - observe({ - shinyjs::hide("fatal_constant") - shinyjs::hide("fatalities_input_type") - shinyjs::hide("fatalities_mean") - shinyjs::hide("fatalities_se") - shinyjs::hide("fatalities_mat_expert") - shinyjs::hide("fatalities_run_expert") - shinyjs::hide("farm_number_cumulated") - shinyjs::hide("fatalities_mat_cumulated") - shinyjs::hide("pop_size_type") - shinyjs::hide("pop_size_input_type") - shinyjs::hide("pop_size_mean") - shinyjs::hide("pop_size_se") - shinyjs::hide("pop_size_mat_expert") - shinyjs::hide("pop_size_run_expert") - shinyjs::hide("carrying_cap_input_type") - shinyjs::hide("carrying_capacity") - shinyjs::hide("carrying_cap_mat_expert") - shinyjs::hide("carrying_cap_run_expert") - shinyjs::hide("lambda_input_type") - shinyjs::hide("pop_growth_mean") - shinyjs::hide("pop_growth_se") - shinyjs::hide("pop_growth_mat_expert") - shinyjs::hide("pop_growth_run_expert") - shinyjs::hide("pop_trend") - shinyjs::hide("pop_trend_strength") - shinyjs::hide("fill_type_vr") - shinyjs::hide("mat_display_vr") - shinyjs::hide("mat_fill_vr") - - # Show fatalities part - - if(input$button_fatalities%%2 == 1){ - shinyjs::show("fatal_constant") - - # Show inputs for none cumulated impacts scenario - - if(input$analysis_choice == "scenario"){ - shinyjs::show("fatalities_input_type") - if(input$fatalities_input_type == "Valeurs"){ - shinyjs::show("fatalities_mean") - shinyjs::show("fatalities_se") - } - if(input$fatalities_input_type == "Elicitation d'expert"){ - shinyjs::show("fatalities_mat_expert") - shinyjs::show("fatalities_run_expert") - } - } - - # Show inputs for cumulated scenario - - if(input$analysis_choice == "cumulated"){ - shinyjs::show("farm_number_cumulated") - shinyjs::show("fatalities_mat_cumulated") - } - - } - - # Show inputs for population size part - - if(input$button_pop_size%%2 == 1){ - shinyjs::show("pop_size_type") - shinyjs::show("pop_size_input_type") - if(input$pop_size_input_type == "Valeurs"){ - shinyjs::show("pop_size_mean") - shinyjs::show("pop_size_se") - } - if(input$pop_size_input_type == "Elicitation d'expert"){ - shinyjs::show("pop_size_mat_expert") - shinyjs::show("pop_size_run_expert") - } - } - - # Show inputs for carrying capacity part - - if(input$button_carrying_cap%%2 == 1){ - shinyjs::show("carrying_cap_input_type") - if(input$carrying_cap_input_type == "Valeurs"){ - shinyjs::show("carrying_capacity") - } - if(input$carrying_cap_input_type == "Elicitation d'expert"){ - shinyjs::show("carrying_cap_mat_expert") - shinyjs::show("carrying_cap_run_expert") - } - } - - # Show inputs for population trend part - - if(input$button_pop_trend%%2 == 1){ - shinyjs::show("lambda_input_type") - if(input$lambda_input_type == "Taux de croissance"){ - shinyjs::show("pop_growth_mean") - shinyjs::show("pop_growth_se") - } - if(input$lambda_input_type == "Elicitation d'expert"){ - shinyjs::show("pop_growth_mat_expert") - shinyjs::show("pop_growth_run_expert") - } - if(input$lambda_input_type == "Tendance locale ou régionale"){ - shinyjs::show("pop_trend") - shinyjs::show("pop_trend_strength") - } - } - - # Show inputs vital rates part - - if(input$button_vital_rates%%2 == 1){ - shinyjs::show("fill_type_vr") - if(input$fill_type_vr == "Automatique"){ - shinyjs::show("mat_display_vr") - } - if(input$fill_type_vr == "Manuelle"){ - shinyjs::show("mat_fill_vr") - } - } - }) - - # Elicitation experts part - - func_eli <- function(mat_expert){ - t_mat_expert <- t(mat_expert) - vals = t_mat_expert[3:5,] - Cp = t_mat_expert[6,] - weights = t_mat_expert[2,] - - out <- elicitation(vals, Cp, weights) - return(list(out = out, mean = out$mean_smooth, SE = sqrt(out$var_smooth))) - } - - func_eli_plot <- function(out){ - plot_elicitation(out) - } - - ## Output - - param <- reactiveValues(N1 = NULL, - fatalities_mean = 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, - rMAX_species = rMAX_species, - theta = theta, - 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) - - # Elicitation - - ## Fatalities - - observeEvent({input$fatalities_run_expert}, { - if(all(is.na(input$fatalities_mat_expert))) {} else { - param$fatalities_eli_result <- func_eli(input$fatalities_mat_expert) - - ### Plot fatalities - output$fatalities_expert_plot <- renderPlot({func_eli_plot(param$fatalities_eli_result$out)})} - }) - - ## Population size - - observeEvent({input$pop_size_run_expert}, { - if(all(is.na(input$pop_size_mat_expert))) {} else { - param$pop_size_eli_result <- func_eli(input$pop_size_mat_expert) - - ### Plot pop size - output$pop_size_expert_plot <- renderPlot({func_eli_plot(param$pop_size_eli_result$out)})} - }) - - ## Population growth - - observeEvent({input$pop_growth_run_expert},{ - if(all(is.na(input$pop_growth_mat_expert))) {} else { - param$pop_growth_eli_result <- func_eli(input$pop_growth_mat_expert) - - ### plot pop growth - output$pop_growth_expert_plot <- renderPlot({func_eli_plot(param$pop_growth_eli_result$out)}) - } - }) - - ## Carrying capacity - - observeEvent({input$carrying_cap_run_expert},{ - if(all(is.na(input$carrying_cap_mat_expert))) {} else { - param$carrying_cap_eli_result <- func_eli(input$carrying_cap_mat_expert) - - ### Plot carrying capacity - output$carrying_cap_expert_plot <- renderPlot({func_eli_plot(param$carrying_cap_eli_result$out)}) - } - }) - - # Reactive values (cumulated impacts, fatalities mean, fatalities se, onset_time, survivals mean, fecundities mean) - - observeEvent({input$run}, { - if(input$analysis_choice == "scenario"){ - param$cumulated_impacts = FALSE - } else { - param$cumulated_impacts = TRUE - } - }) - - # Fatalities - ## onset time, mean and se - - observeEvent({input$run}, { - if(input$analysis_choice == "scenario"){ - if(input$fatalities_input_type == "Elicitation d'expert"){ - if(!(is.null(param$fatalities_eli_result))) { - param$fatalities_mean <- c(0, round(param$fatalities_eli_result$mean)) - param$onset_time = NULL - param$fatalities_se <- c(0, round(param$fatalities_eli_result$SE)) - } else { - print("#Intégrer un message d'erreur") - } - } else { - param$fatalities_mean <- c(0, input$fatalities_mean) - param$onset_time = NULL - param$fatalities_se <- c(0, input$fatalities_se) - } - } else { - param$fatalities_mean <- c(0, input$fatalities_mat_cumulated[,1]) - param$onset_year <- c(min(input$fatalities_mat_cumulated[,3]), input$fatalities_mat_cumulated[,3]) - param$onset_time <- param$onset_year - min(param$onset_year) + 1 - param$fatalities_se <- c(0, input$fatalities_mat_cumulated[,2]) - } - }) - - # Population size - ## Mean, se and type - - observeEvent({input$run},{ - if(input$pop_size_input_type == "Elicitation d'expert"){ - if(!(is.null(param$pop_size_eli_result))){ - param$pop_size_mean <- round(param$pop_size_eli_result$mean) - param$pop_size_se <- round(param$pop_size_eli_result$SE) - } else { - print("#intégrer un message d'erreur") - } - } else { - param$pop_size_mean <- input$pop_size_mean - param$pop_size_se <- input$pop_size_se - } - param$pop_size_type <- input$pop_size_type - }) - - # Observe pop growth value - ## Avoid unrealistic scenarios - - observeEvent({input$run}, { - if(input$lambda_input_type == "Elicitation d'expert"){ - if(!(is.null(param$pop_growth_eli_result))){ - param$pop_growth_mean <- round(min(1 + param$rMAX_species, round(param$pop_growth_eli_result$mean, 2)), 2) - param$pop_growth_se <- round(param$pop_growth_eli_result$SE, 2) - } else { - print("#intégrer un message d'erreur") - } - } else if(input$lambda_input_type == "Tendance locale ou régionale"){ - if(input$pop_trend == "Croissance") { - if(input$pop_trend_strength == "Faible") { - param$pop_growth_mean <- 1.01 - } else if(input$pop_trend_strength == "Moyen"){ - param$pop_growth_mean <- 1.03 - } else { - param$pop_growth_mean <- 1.06 - } - } else if(input$pop_trend == "Déclin"){ - if(input$pop_trend_strength == "Faible") { - param$pop_growth_mean <- 0.99 - } else if(input$pop_trend_strength == "Moyen"){ - param$pop_growth_mean <- 0.97 - } else { - param$pop_growth_mean <- 0.94 - } - } else { - param$pop_growth_mean <- 1 - } - param$pop_growth_se <- 0.03 - } - else { - param$pop_growth_mean <- round(min(1 + param$rMAX_species, input$pop_growth_mean), 2) - param$pop_growth_se <- input$pop_growth_se - } - }) - - # Survivals and fecundities - - observeEvent({input$run}, { - if(input$fill_type_vr == "Manuelle"){ - param$survivals <- input$mat_fill_vr[,1] - param$fecundities <- input$mat_fill_vr[,2] - } else { - param$survivals <- survivals - param$fecundities <- fecundities - } - }) - - # Survival and fecundity calibration - - observeEvent({ - input$run - # input$species_choice - # input$pop_growth_mean - },{ - - ## Avoid unrealistic scenarios - #param$pop_growth_mean <- min(1 + param$rMAX_species, input$pop_growth_mean) - - param$vr_calibrated <- calibrate_params( - inits = init_calib(s = param$survivals, f = param$fecundities, lam0 = param$pop_growth_mean), - f = param$fecundities, s = param$survivals, lam0 = param$pop_growth_mean - ) - param$s_calibrated <- head(param$vr_calibrated, length(param$survivals)) - param$f_calibrated <- tail(param$vr_calibrated, length(param$fecundities)) - }) - - - # Observe carrying capacity - observeEvent({input$run}, { - if(input$carrying_cap_input_type == "Elicitation d'expert"){ - if(!(is.null(param$carrying_cap_eli_result))){ - param$carrying_capacity <- round(param$carrying_cap_eli_result$mean) - } else { - print("#intégrer un message d'erreur") - } - } else { - param$carrying_capacity <- input$carrying_capacity - } - }) - - observeEvent({input$run}, { - print(param$pop_growth_mean) - print(param$pop_growth_se) - }) - - # End of reactive - - # Simulations - - observeEvent({ - input$run - }, { - - withProgress(message = 'Simulation progress', value = 0, { - - param$N1 <- run_simul_shiny(nsim = input$nsim, - cumuated_impacts = param$cumulated_impacts, - - fatalities_mean = param$fatalities_mean, - fatalities_se = param$fatalities_se, - onset_time = param$onset_time, - - pop_size_mean = param$pop_size_mean, - pop_size_se = param$pop_size_se, - pop_size_type = param$pop_size_type, - - pop_growth_mean = param$pop_growth_mean, - pop_growth_se = param$pop_growth_se, - - survivals = param$s_calibrated, - fecundities = param$f_calibrated, - - carrying_capacity = param$carrying_capacity, - 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) - }) # Close withProgress - }) # Close observEvent - - - # Plot Impacts - - plot_out_impact <- function(){ - if(is.null(param$N1)) {} else {plot_impact(N = param$N1$N, xlab = "year", ylab = "pop size")} - } - - output$graph_impact <- renderPlot({ - plot_out_impact() - }) - - # Plot trajectories - - plot_out_traj <- function(){ - if(is.null(param$N1)) {} else {plot_traj(N = param$N1$N, xlab = "year", ylab = "pop size")} - } - - output$graph_traj <- renderPlot({ - plot_out_traj() - }) - # End simulations - - # General informations output - - ## Fatalities - - output$fatalities_mean_info <- renderText({ - if(input$fatalities_input_type == "Elicitation d'expert"){ - if(!(is.null(param$fatalities_eli_result))){ - info <- round(param$fatalities_eli_result$mean) - } else {info <- NA} - } - else { - info <- input$fatalities_mean - } - paste0("Moyenne des mortalités : ", info) - }) - - output$fatalities_se_info <- renderText({ - if(input$fatalities_input_type == "Elicitation d'expert"){ - if(!(is.null(param$fatalities_eli_result))){ - info <- round(param$fatalities_eli_result$SE) - } else {info <- NA} - } - else { - info <- input$fatalities_se - } - paste0("Ecart-type des mortalités : ", info) - }) - - ## Poplutation size - - output$pop_size_type_info <- renderText({ - if(input$pop_size_type == "Npair"){ - paste0("Type de taille de pop : ", "Nombre de couple") - } else { - paste0("Type de taille de pop : ", "Effectif total") - } - }) - - output$pop_size_mean_info <- renderText({ - if(input$pop_size_input_type == "Elicitation d'expert"){ - if(!(is.null(param$pop_size_eli_result))){ - info <- round(param$pop_size_eli_result$mean) - } else {info <- NA} - } - else { - info <- input$pop_size_mean - } - paste0("Moyenne de la taille de la population : ", info) - }) - - output$pop_size_se_info <- renderText({ - if(input$pop_size_input_type == "Elicitation d'expert"){ - if(!(is.null(param$pop_size_eli_result))){ - info <- round(param$pop_size_eli_result$SE) - } else {info <- NA} - } - else { - info <- input$pop_size_se - } - paste0("Ecart-type de la taille de la population : ", info) - }) - - ## Carrying capacity - - output$carrying_capacity_info <- renderText({ - if(input$carrying_cap_input_type == "Elicitation d'expert"){ - if(!(is.null(param$carrying_cap_eli_result))){ - info <- round(param$carrying_cap_eli_result$mean) - } else {info <- NA} - } - else { - info <- input$carrying_capacity - } - paste0("Capacité de charge du milieu : ", info) - }) - - ## Population growth - - output$pop_trend_type_info <- renderText({paste0("Type de Tendance de pop : ", input$lambda_input_type)}) - - output$pop_growth_mean_info <- renderText({ - if(input$lambda_input_type == "Elicitation d'expert"){ - if(!(is.null(param$pop_growth_eli_result))){ - info <- round(param$pop_growth_eli_result$mean, 2) - } else {info <- NA} - } else if(input$lambda_input_type == "Tendance locale ou régionale"){ - if(input$pop_trend == "Croissance") { - if(input$pop_trend_strength == "Faible") { - info <- 1.01 - } else if(input$pop_trend_strength == "Moyen"){ - info <- 1.03 - } else { - info <- 1.06 - } - } else if(input$pop_trend == "Déclin"){ - if(input$pop_trend_strength == "Faible") { - info <- 0.99 - } else if(input$pop_trend_strength == "Moyen"){ - info <- 0.97 - } else { - info <- 0.94 - } - } else { - info <- 1.00 - } - } else { - info <- input$pop_growth_mean - } - paste0("Moyenne de la croissance de la population : ", info) - }) - - output$pop_growth_se_info <- renderText({ - if(input$lambda_input_type == "Elicitation d'expert"){ - if(!(is.null(param$pop_growth_eli_result))){ - info <- round(param$pop_growth_eli_result$SE, 2) - } else {info <- NA} - } else if (input$lambda_input_type == "Tendance locale ou régionale") { - info <- 0.03 - } - else { - info <- input$pop_growth_se - } - paste0("Ecart-type de la croissance de la population : ", info) - }) - - ## Vital rates - - output$vital_rates_info <- renderTable({ - if(input$fill_type_vr == "Automatique"){ - input$mat_display_vr - } else { - input$mat_fill_vr - } - }) - # End genral informations output - - ## Update matrix cumulated impact - - observeEvent({ - input$farm_number_cumulated - }, { - - park_names <- function(n){ - v <- c(paste0("Parc n°", c(1:n))) - return(v) - } - - n_row <- input$farm_number_cumulated - - updateMatrixInput(session, inputId = "fatalities_mat_cumulated", - value = matrix(init_cumul, nrow = n_row, 3, byrow = TRUE, - dimnames = list(park_names(n_row), - c("Moyenne", - "Ecart-type", - "Année de mise en service du parc")))) - }) # end observEvent - - # Survivals and Fecundities - - create.matrice <- function(species){ - tab_test <- data_sf %>% - filter(species == data_sf$Nom_espece) %>% - select(classes_age, survie, fecondite) - return(tab_test) - } - - observeEvent({input$species_list}, { - if(input$species_list == "Espèce") {} else { - tab_species <- create.matrice(input$species_list) - - if(all(is.na(tab_species))) { - updateMatrixInput(session, inputId = "mat_fill_vr", - value = matrix(data = "", - nrow = 4, - ncol = 2, - dimnames = list(c("Juv 1", "Juv 2", "Juv 3", "Adulte"), c("Survie", "Fécondité")))) - - } else { - number_age_class <- nrow(tab_species) - ages <- tab_species$classes_age - survivals <- tab_species$survie - fecundities <- tab_species$fecondite - - updateMatrixInput(session, inputId = "mat_fill_vr", - value = matrix(data = c(survivals, fecundities), - nrow = number_age_class, - ncol = 2, - dimnames = list(ages, c("Survie", "Fécondité")))) - } - } - }) -} -# End server - - - diff --git a/inst/ShinyApp/ui_old.R b/inst/ShinyApp/ui_old.R deleted file mode 100644 index 47624bc..0000000 --- a/inst/ShinyApp/ui_old.R +++ /dev/null @@ -1,389 +0,0 @@ -rm(list = ls(all.names = TRUE)) - -## Load libraries -library(shiny) -library(shinyjs) -library(shinyMatrix) -library(tidyverse) -library(eolpop) - - -# source("./inst/ShinyApp/f_output.R") -# source("./inst/ShinyApp/param_fixes.R") - -## Load species list -species_data <- read.csv("./inst/ShinyApp/species_list.csv", sep = ",") -species_list <- unique(as.character(species_data$NomEspece)) -# species_list <- species_data$NomEspece - -## Load survival and fecundities data -data_sf <- read.csv("./inst/ShinyApp/survivals_fecundities_species.csv", sep = ",")#, encoding = "UTF-8") -(data_sf) - -# Fixed parameters (for now) -nsim = 10 -coeff_var_environ = 0.10 -time_horzion = 30 -survivals <- c(0.5, 0.7, 0.8, 0.95) -fecundities <- c(0, 0, 0.05, 0.55) - -## Data elicitation pre-fill data -# fatalities -eli_fatalities <- c("A", 1.0, 2, 5, 8, 0.80, - "B", 0.2, 0, 3, 6, 0.90, - "C", 0.2, 2, 4, 10, 0.90, - "D", 0.1, 1, 3, 7, 0.70) - -# population size -eli_pop_size <- c("A", 1.0, 150, 200, 250, 0.80, - "B", 0.5, 120, 180, 240, 0.90, - "C", 0.8, 170, 250, 310, 0.90, - "D", 0.3, 180, 200, 230, 0.70) - -# carrying capacity -eli_carrying_cap <- c("A", 1.0, 500, 700, 1000, 0.80, - "B", 0.5, 1000, 1500, 2000, 0.90, - "C", 0.8, 800, 1200, 1600, 0.90, - "D", 0.3, 100, 1200, 1500, 0.70) - -# population growth rate -eli_pop_growth <- c("A", 1 , 0.95, 0.98, 1.00, 0.95, - "B", 0.2, 0.97, 1.00, 1.01, 0.90, - "C", 0.5, 0.92, 0.96, 0.99, 0.90, - "D", 0.3, 0.90, 0.95, 0.98, 0.70) - -## Other pre-fill data -# fatalities for several wind farms (cumulated impacts) -init_cumul <- c(10, 5, 8, - 0.05, 0.05, 0.05, - 2010, 2015, 2018) -init_cumul_add <- c(3, 0.05, 2020) - - - -# vital rates -init_vr = c(survivals, fecundities) - -# DD parameters -theta = 1 - -# Define theoretical rMAX for the species -rMAX_species <- rMAX_spp(surv = tail(survivals, 1), afr = min(which(fecundities != 0))) -rMAX_species - - -##-------------------------------------------- -## User Interface -- -##-------------------------------------------- -ui <- fluidPage( - useShinyjs(), - titlePanel("eolpop : Impact demographique des éoliennes"), - - # Creation of the first page (select species, analysis type choice) - - wellPanel( - selectInput(inputId = "species_list", - h4(strong("Sélection d'une espèce")), - choices = species_list), - radioButtons(inputId = "analysis_choice", - h4(strong("Sélectionner un type d'analyse")), - choices = c("Impacts non cumulés" = "scenario", "Impacts cumulés" = "cumulated")) - ), # End wellPanel - - - ##-------------------------------------------- - ## General information -- - ##-------------------------------------------- - - wellPanel( - fluidRow( - column(width = 4, - textOutput(outputId = "specie_name"), - h4("Mortalités"), - textOutput(outputId = "fatalities_mean_info"), - textOutput(outputId = "fatalities_se_info"), - h4("Taille de la population"), - textOutput(outputId = "pop_size_type_info"), - textOutput(outputId = "pop_size_mean_info"), - textOutput(outputId = "pop_size_se_info")), - fluidRow( - column(width = 4, - h4("Capacité de charge"), - textOutput(outputId = "carrying_capacity_info"), - h4("Tendance de la population"), - textOutput(outputId = "pop_trend_type_info"), - textOutput(outputId = "pop_growth_mean_info"), - textOutput(outputId = "pop_growth_se_info")), - fluidRow( - column(width = 4, - h4("Paramètres démographiques"), - tableOutput(outputId = "vital_rates_info")) - ) - ) - ) - ), # End wellPanel - - - # Paramter Inputs (fatalities, pop size, carrying capacity, pop trend and vital rates). - - sidebarLayout( - sidebarPanel( - - ##-------------------------------------------- - ## 1. Fatalities -- - ##-------------------------------------------- - - actionButton(inputId = "button_fatalities", - label = "Mortalités"), - radioButtons(inputId = "fatal_constant", - label = h4("Modélisation"), - choices = c("Taux de mortalités (h) constant" = "h", - "Nombre de mortalités (M) constant" = "M")), - - ### Part for non-cumulated impacts - # Input type - radioButtons(inputId = "fatalities_input_type", - label = h4("Source des données"), - choices = c("Valeurs", "Elicitation d'expert")), - - # Values - numericInput(inputId = "fatalities_mean", - label = "Moyenne des mortalités annuelles", - value = 5, - min = 0, max = Inf, step = 0.5), - numericInput(inputId = "fatalities_se", - label = "Ecart-type des mortalités annuelles", - value = 0.05, - min = 0, max = Inf, step = 0.1), - - # Matrix for expert elicitation - matrixInput(inputId = "fatalities_mat_expert", - value = matrix(data = eli_fatalities, 4, 6, - dimnames = list(c("#1", "#2", "#3", "#4"), - c("Nom", "Poids", "Min", "Best", "Max", "% IC" )), - byrow = TRUE), - class = "numeric", - rows = list(names = TRUE), - cols = list(names = TRUE)), - - actionButton(inputId = "fatalities_run_expert", label = "Analyse"), - - ### Part for cumulated impacts - - numericInput(inputId = "farm_number_cumulated", - label = "Nombre de parcs éoliens", - value = 3, min = 2, max = Inf, step = 1), - - matrixInput(inputId = "fatalities_mat_cumulated", - value = matrix(init_cumul, 3, 3, - dimnames = list(c(paste0("Parc n°", c(1:3))), - c("Moyenne", - "Ecart-type", - "Année de mise en service du parc"))), - class = "numeric", - rows = list(names = TRUE), - cols = list(names = TRUE)), - - - ##-------------------------------------------- - ## 2. Population Size -- - ##-------------------------------------------- - - br(" "), - actionButton(inputId = "button_pop_size", - label = "Taille de la population"), - - radioButtons(inputId = "pop_size_type", - label = h4("Unité"), - choices = c("Nombre de couple" = "Npair", "Effectif total" = "Ntotal")), - - radioButtons(inputId = "pop_size_input_type", - label = h4("Type de saisie"), - choices = c("Valeurs", "Elicitation d'expert")), - - numericInput(inputId = "pop_size_mean", - label = "Moyenne de la taille de la population", - value = 200, - min = 0, max = Inf, step = 50), - - numericInput(inputId = "pop_size_se", - label = "Ecart-type de la taille de la population", - value = 25, - min = 0, max = Inf, step = 1), - - matrixInput(inputId = "pop_size_mat_expert", - value = matrix(data = eli_pop_size, 4, 6, - dimnames = list(c("#1", "#2", "#3", "#4"), - c("Nom", "Poids", "Min", "Best", "Max", "% IC" )), - byrow = TRUE), - class = "numeric", - rows = list(names = TRUE), - cols = list(names = TRUE)), - - actionButton(inputId = "pop_size_run_expert", label = "Analyse"), - - - ##-------------------------------------------- - ## 3. Carrying capacity -- - ##-------------------------------------------- - - br(" "), - actionButton(inputId = "button_carrying_cap", - label = "Capacité de charge"), - - radioButtons(inputId = "carrying_cap_input_type", - label = h4("Type d'unité"), - choices = c("Valeurs", "Elicitation d'expert")), - - numericInput(inputId = "carrying_capacity", - label = "Capacité de charge", - value = 1000, - min = 0, max = Inf, step = 100), - - matrixInput(inputId = "carrying_cap_mat_expert", - value = matrix(data = eli_carrying_cap, 4, 6, - dimnames = list(c("#1", "#2", "#3", "#4"), - c("Nom", "Poids", "Min", "Best", "Max", "% IC" )), - byrow = TRUE), - class = "numeric", - rows = list(names = TRUE), - cols = list(names = TRUE)), - - actionButton(inputId = "carrying_cap_run_expert", label = "Analyse"), - - ##-------------------------------------------- - ## 4. Population Trend -- - ##-------------------------------------------- - - br(" "), - actionButton(inputId = "button_pop_trend", - label = "Tendance de la population"), - - radioButtons(inputId = "lambda_input_type", - label = h4("Type de tendance"), - choices = c("Taux de croissance", "Elicitation d'expert", "Tendance locale ou régionale")), - - numericInput(inputId = "pop_growth_mean", - label = "Moyenne de la croissance de la population", - value = 1, - min = 0, max = Inf, step = 0.01), - - numericInput(inputId = "pop_growth_se", - label = "Ecart-type de la croissance de la population", - value = 0, - min = 0, max = Inf, step = 0.01), - - matrixInput(inputId = "pop_growth_mat_expert", - value = matrix(data = eli_pop_growth, 4, 6, - dimnames = list(c("#1", "#2", "#3", "#4"), - c("Nom", "Poids", "Min", "Best", "Max", "% IC" )), - byrow = TRUE), - class = "numeric", - rows = list(names = TRUE), - cols = list(names = TRUE)), - - actionButton(inputId = "pop_growth_run_expert", label = "Analyse"), - - h4("Tendance de la population"), - - radioButtons(inputId = "pop_trend", - label = NULL, - choices = c("Croissance", "Stable", "Déclin")), - - radioButtons(inputId = "pop_trend_strength", - label = NULL, - choices = c("Faible", "Moyen", "Fort")), - - # tags$style("#pop_trend_strength {position:fixed; top: 600px; right: 100px;}"), - - - ##-------------------------------------------- - ## 5. Vital rates -- - ##-------------------------------------------- - - br(" "), - actionButton(inputId = "button_vital_rates", - label = "Paramètres démographiques"), - - radioButtons(inputId = "fill_type_vr", - label = "Type de saisie", - choices = c("Automatique", "Manuelle")), - - # tableOutput(outputId = "mat_display_vr"), - - matrixInput(inputId = "mat_display_vr", - value = matrix("", 4, 2, dimnames = list(c("Juv 1", "Juv 2", "Juv 3", "Adulte"), c("Survie", "Fécondité"))), - class = "numeric", - rows = list(names = TRUE), - cols = list(names = TRUE)), - - matrixInput(inputId = "mat_fill_vr", - value = matrix(data = init_vr, 4, 2, dimnames = list(c("Juv 1", "Juv 2", "Juv 3", "Adulte"), c("Survie", "Fécondité"))), - class = "numeric", - rows = list(names = TRUE), - cols = list(names = TRUE)) - - ), # End sidebarPanel - - - #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - - # Creation of outputs parts - - mainPanel( - tabsetPanel( - tabPanel(title = "Impact population", - strong(span(textOutput("message"), style="color:blue; font-size:24px", align = "center")), - br(), - numericInput(inputId = "nsim", label = "Nombre de simulations", - value = 50, min = 0, max = Inf, step = 10), - br(), - actionButton(inputId = "run", label = "Lancer l'analyse"), - hr(), - h4("Graphique : Impact relatif de chaque scénario", align = "center"), - plotOutput("graph_impact", width = "100%", height = "550px"), - hr(), - h4("Graphique : Trajectoire démographique", align = "center"), - plotOutput("graph_traj", width = "100%", height = "550px")), - - tabPanel(title = "Distribution paramètres", - br(), - hr(), - h4("#Graphe élicitation d'expert pour les mortalités", align = "center"), - plotOutput(outputId = "fatalities_expert_plot"), - hr(), - h4("#Graphe élicitation d'expert pour la taille de la population", align = "center"), - plotOutput(outputId = "pop_size_expert_plot"), - hr(), - h4("#Graphe élicitation d'expert pour la capacité de charge", align = "center"), - plotOutput(outputId = "carrying_cap_expert_plot"), - hr(), - h4("#Graphe élicitation d'expert pour la tendance de la population", align = "center"), - plotOutput(outputId = "pop_growth_expert_plot"), - ), - - tabPanel(title = "Rapport", - br(), - radioButtons(inputId = "lifestyle", - h4("Mode de vie de l'espèce"), - choices = c("Sédentaire", "Non-sédentaire nicheur", "Non-sédentaire hivernant", "Migrateur de passage")), - numericInput(inputId = "wind_turbines", - h4("Nombre d'éoliennes"), - value = 5, min = 0, max = Inf, step = 1), - numericInput(inputId = "farm_number", - h4("Nombre de parcs"), - value = 1, min = 0, max = Inf, step = 1), - numericInput(inputId = "wind_turbines_2", - h4("Nombre d'éoliennes"), - value = 1, min = 0, max = Inf, step = 1) - - ) # End tabPanel - ) # End tabSetPanel - ) # End mainPanel - ) # sidebarLayout -) # FluidPage - -# End UI - -- GitLab