Newer
Older
rm(list = ls(all.names = TRUE))
library(shiny)
library(shinyjs)
library(shinyMatrix)
library(tidyverse)
library(eolpop)
# source("./inst/ShinyApp/f_output.R")
species_data <- read.csv("./inst/ShinyApp/species_list.csv", sep = ",")
head(species_data)
# species_list <- unique(as.character(species_data$NomEspece))
species_list <- species_data$NomEspece
data_sf <- read.csv("./inst/ShinyApp/survivals_fecundities_species.csv", sep = ",")#, encoding = "UTF-8")
head(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, fatalities for cumulated impacts, vital rates and DD_params
data_eli = c("",1, 50, 70, 100, 0.80, "", 0.2, 200, 240, 280, 0.90, "", 0.2, 100, 180, 300, 0.90,"", 0.1, 120, 160, 220, 0.70)
data_eli_trend = c("", 1, 0.60, 0.66, 0.78, 0.80, "", 0.2, 0.75, 0.83, 0.89, 0.90, "", 0.2, 0.56, 0.67, 0.77, 0.90, "", 0.1, 0.76, 0.89, 0.94, 0.70)
data_fatalities = c(10, 5, 8, 0.05, 0.05, 0.05, 2010, 2015, 2018)
# Define theoretical rMAX for the species
rMAX_species <- rMAX_spp(surv = tail(survivals,1), afr = min(which(fecundities != 0)))
rMAX_species
##--------------------------------------------
## User Interface --
##--------------------------------------------
titlePanel("eolpop : Impact demographique des oliennes"),
# Creation of the first page (select species, analysis type choice)
wellPanel(
selectInput(inputId = "species_list",
h4(strong("Slection d'une espce ou groupe d'espces")),
choices = species_list),
radioButtons(inputId = "analysis_choice",
h4(strong("Slectionner un type d'analyse")),
choices = c("Impacts non cumuls" = "scenario", "Impacts cumuls" = "cumulated"))
##--------------------------------------------
## General information --
##--------------------------------------------
textOutput(outputId = "fatalities_mean_info"),
textOutput(outputId = "fatalities_se_info"),
h4("Taille de la population"),
textOutput(outputId = "pop_size_type_info"),
textOutput(outputId = "carrying_capacity_info"),
h4("Tendance de la population"),
textOutput(outputId = "pop_growth_mean_info"),
textOutput(outputId = "pop_growth_se_info")),
fluidRow(
column(width = 4,
# Paramter Inputs (fatalities, pop size, carrying capacity, pop trend and vital rates).
##--------------------------------------------
## 1. Fatalities --
##--------------------------------------------
label = h4("Modlisation"),
choices = c("Taux de mortalits (h) constant" = "h",
"Nombre de mortalits (M) constant" = "M")),
label = h4("Source des donnes"),
label = "Moyenne des mortalits annuelles",
label = "Ecart-type des mortalits annuelles",
min = 0, max = Inf, step = 0.1),
# Matrix for expert elicitation
matrixInput(inputId = "fatalities_mat_expert",
value = matrix(data = data_eli, 4, 6, dimnames = list(c("#1", "#2", "#3", "#4"), c("Nom", "Poids", "Min", "Meilleure Estimation", "Max", "IC (coverage)" )), byrow = TRUE),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
actionButton(inputId = "fatalities_run_expert", label = "Analyse"),
### Part for cumulated impacts
label = "Nombre de parcs oliens",
dimnames = list(c(paste0("Parc n", c(1:3))),
c("Moyennes des mortalits annuelles",
"Ecart-type des mortalits annuelles",
"Anne 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"),
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,
numericInput(inputId = "pop_size_se",
label = "Ecart-type de la taille de la population",
value = 25,
min = 0, max = Inf, step = 1),
value = matrix(data = data_eli, 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(" "),
value = matrix(data = data_eli, 4, 6, dimnames = list(c("#1", "#2", "#3", "#4"), c("Nom", "Poids", "Min", "Meilleure Estimation", "Max", "IC (coverage)" )), byrow = TRUE),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
actionButton(inputId = "carrying_cap_run_expert", label = "Analyse"),
##--------------------------------------------
## 4. Population Trend --
##--------------------------------------------
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 rgionale")),
numericInput(inputId = "pop_growth_mean",
label = "Moyenne de la croissance de la population",
value = 1,
numericInput(inputId = "pop_growth_se",
label = "Ecart-type de la croissance de la population",
value = matrix(data = data_eli_trend, 4, 6, dimnames = list(c("#1", "#2", "#3", "#4"), c("Nom", "Poids", "Min", "Meilleure Estimation", "Max", "IC (coverage)" )), 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"),
choices = c("Croissance", "Stable", "Dclin")),
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(" "),
label = "Paramtres dmographiques"),
radioButtons(inputId = "fill_type_vr",
label = "Type de saisie",
choices = c("Automatique", "Manuelle")),
value = matrix("", 4, 2, dimnames = list(c("Juv 1", "Juv 2", "Juv 3", "Adulte"), c("Survie", "Fcondit"))),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
value = matrix(data = data_vr, 4, 2, dimnames = list(c("Juv 1", "Juv 2", "Juv 3", "Adulte"), c("Survie", "Fcondit"))),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE))
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mainPanel(
tabsetPanel(
tabPanel(title = "Impact population",
strong(span(textOutput("message"), style="color:blue; font-size:24px", align = "center")),
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 scnario", align = "center"),
plotOutput("graph_impact", width = "100%", height = "550px"),
hr(),
h4("Graphique : Trajectoire dmographique", align = "center"),
tabPanel(title = "Distribution paramtres",
h4("#Graphe licitation d'expert pour les mortalits", align = "center"),
h4("#Graphe licitation d'expert pour la taille de la population", align = "center"),
h4("#Graphe licitation d'expert pour la capacit de charge", align = "center"),
h4("#Graphe licitation d'expert pour la tendance de la population", align = "center"),
tabPanel(title = "Rapport",
br(),
radioButtons(inputId = "lifestyle",
h4("Mode de vie de l'espce"),
choices = c("Sdentaire", "Non-sdentaire nicheur", "Non-sdentaire hivernant", "Migrateur de passage")),
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",
) # End tabPanel
) # End tabSetPanel
) # End mainPanel