Newer
Older
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Initial stuff
{
## Load libraries
library(shiny)
library(shinyjs)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
library(shinyMatrix)
library(tidyverse)
library(eolpop)
## Load species list
species_data <- read.csv("./inst/ShinyApp/species_list.csv", sep = ",")
species_list <- unique(as.character(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
theta = 1 # DD parameter theta
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Pre-fill data
{
## Data elicitation pre-fill data
# fatalities
eli_fatalities <- c(1.0, 2, 5, 8, 0.80,
0.2, 0, 3, 6, 0.90,
0.2, 2, 4, 10, 0.90,
0.1, 1, 3, 7, 0.70)
# population size
eli_pop_size <- c(1.0, 150, 200, 250, 0.80,
0.5, 120, 180, 240, 0.90,
0.8, 170, 250, 310, 0.90,
0.3, 180, 200, 230, 0.70)
# carrying capacity
eli_carrying_cap <- c(1.0, 500, 700, 1000, 0.80,
0.5, 1000, 1500, 2000, 0.90,
0.8, 800, 1200, 1600, 0.90,
0.3, 100, 1200, 1500, 0.70)
# population growth rate
eli_pop_growth <- c(1 , 0.95, 0.98, 1.00, 0.95,
0.2, 0.97, 1.00, 1.01, 0.90,
0.5, 0.92, 0.96, 0.99, 0.90,
0.3, 0.90, 0.95, 0.98, 0.70)
## Other pre-fill data
# fatalities for several wind farms (cumulated impacts)
set.seed(seed = 200)
init_cumul <-
matrix(
round(c(
runif(n = 20, 1, 10),
runif(n = 20, 0.01, 0.20),
sort(sample(x = 2000:2050, size = 20, replace = TRUE))
), 2),
nrow = 20, ncol = 3, byrow = FALSE)
# Undo last 'set.seed'
set.seed( ((((Sys.time() %>% as.numeric) %% 1e10) * 1e9) %% 1e5) %>% round )
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
titlePanel("eolpop : Impact demographique des oliennes"),
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
# Head Panel 1 : type of analysis and species
{wellPanel(
{fluidRow(
# Select type of analysis : cumulated impacted or not
{column(width = 4,
# radioButton : Choix du type d'analyse
{radioButtons(inputId = "analysis_choice",
label = h4(strong("Type d'analyse"),
bsButton("Q_analysis_choice", label = "", icon = icon("question"), size = "extra-small"),
bsPopover(id = "Q_analysis_choice",
title = "Choix du type d\\'analyse",
content = HTML(
"<b>Impacts non cumuls</b> : pour analyser l\\'impact d\\'<b>un seul parc olien</b>. <br><br> <b>Impact cumuls</b> : pour analyser l\\'impact de <b>plusieurs parcs oliens</b> (attention : il faudra fournir des valeurs de mortalits propres chaque parc)."
),
placement = "right",
trigger = "click",
options = list(container='body')
)
),
choices = c("Impacts non cumuls" = "scenario", "Impacts cumuls" = "cumulated")
)},
# Choix de l'espce (selectInput)
{selectInput(inputId = "species_choice",
label = h4(strong("Slectionner une espce"),
bsButton("Q_species_choice", label = "", icon = icon("question"), size = "extra-small"),
bsPopover(id = "Q_species_choice",
title = "Choix de l\\'espce",
content = HTML(
"Ncessaire pour fixer les valeurs de <b>paramtres dmographiques</b> (survie, fcondit). <br> La liste fournie correspond une liste d\\'espces prioritaires. Au besoin, une option \\'espce gnrique\\' est disponible la fin de la liste."
),
placement = "right",
trigger = "click",
options = list(container='body')
)
),
choices = species_list)},
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
)}, # close column
# Show vital rate values
{column(width = 4,
fluidRow(
h4(strong("Paramtres dmographiques")),
tableOutput(outputId = "vital_rates_info"),
),
)}, # close column
## Modify vital rates (if needed)
{column(width = 4,
tags$style(HTML('#button_vital_rates{background-color:#C2C8D3}')),
actionButton(inputId = "button_vital_rates",
label = tags$span("Modifier les paramtres dmographiques",
style = "font-weight: bold; font-size: 18px;")
),
br(),
matrixInput(inputId = "mat_fill_vr",
label = "",
value = matrix(data = NA, 3, 2,
dimnames = list(c("Juv 1", "Juv 2", "Adulte"), c("Survie", "Fcondit"))),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)
)
)}, # close column
)}, # End fluidRow
)}, # End wellPanel
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
# Head Panel 2 : Model parameters
{wellPanel(
p("Saisie des paramtres", style="font-size:28px"),
{fluidRow(
##~~~~~~~~~~~~~~~~~~~~~~~~~
## 1. Fatalities
##~~~~~~~~~~~~~~~~~~~~~~~~~
{column(width = 3,
tags$style(HTML('#button_fatalities{background-color:#C2C8D3}')),
actionButton(inputId = "button_fatalities", width = '100%',
label = tags$span("Mortalits annuelles", style = "font-weight: bold; font-size: 18px;")
),
### Part for non-cumulated impacts
# Input type
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
{conditionalPanel("output.hide_fatalities",
br(),
{wellPanel(style = "background:#F0F8FF",
radioButtons(inputId = "fatalities_input_type",
label = "Type de saisie",
choices = c("Valeurs" = "val", "Elicitation d'expert" = "eli_exp")),
# Values
numericInput(inputId = "fatalities_mean",
label = "Moyenne des mortalits annuelles",
value = 5,
min = 0, max = Inf, step = 0.5),
numericInput(inputId = "fatalities_se",
label = "Erreur-type des mortalits 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, nrow = 4, ncol = 5,
dimnames = list(c("#1", "#2", "#3", "#4"),
c("Poids", "Min", "Best", "Max", "% IC" )),
byrow = TRUE),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
actionButton(inputId = "fatalities_run_expert", label = "Utiliser valeurs experts"),
### 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 num.", c(1:3))),
c("Moyenne",
"Erreur-type",
"Anne de mise en service du parc"))),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
)}, # close wellPanel
)}, # close conditional panel
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
##~~~~~~~~~~~~~~~~~~~~~~~~~
## 2. Population Size
##~~~~~~~~~~~~~~~~~~~~~~~~~
{column(width = 3,
tags$style(HTML('#button_pop_size{background-color:#C2C8D3}')),
actionButton(inputId = "button_pop_size", width = '100%',
label = tags$span("Taille de la population", style = "font-weight: bold; font-size: 18px;")
),
{conditionalPanel("output.hide_pop_size",
br(),
{wellPanel(style = "background:#FFF8DC",
radioButtons(inputId = "pop_size_unit", inline = TRUE,
label = "Unit",
choices = c("Nombre de couple" = "Npair", "Effectif total" = "Ntotal"),
selected = "Ntotal"),
)}, # close wellPanel 1
{wellPanel(style = "background:#F0F8FF",
radioButtons(inputId = "pop_size_input_type",
label = "Type de saisie",
choices = c("Valeurs" = "val", "Elicitation d'expert" = "eli_exp")),
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 = "Erreur-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, nrow = 4, ncol = 5,
dimnames = list(c("#1", "#2", "#3", "#4"),
c("Poids", "Min", "Best", "Max", "% IC" )),
byrow = TRUE),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
actionButton(inputId = "pop_size_run_expert", label = "Utiliser valeurs experts"),
)}, # close wellPanel 2
)}, # close conditional panel
)}, # end column "mortalite"
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
##~~~~~~~~~~~~~~~~~~~~~~~~~
## 3. Population Growth
##~~~~~~~~~~~~~~~~~~~~~~~~~
{column(width = 3,
tags$style(HTML('#button_pop_growth{background-color:#C2C8D3}')),
actionButton(inputId = "button_pop_growth", width = '100%',
label = tags$span("Tendance de la population", style = "font-weight: bold; font-size: 18px;")
),
{conditionalPanel("output.hide_pop_growth",
br(),
{wellPanel(style = "background:#F0F8FF",
radioButtons(inputId = "pop_growth_input_type",
label = "Type de saisie",
choices = c("Taux de croissance" = "val",
"Elicitation d'expert" = "eli_exp",
"Tendance locale ou rgionale" = "trend")),
numericInput(inputId = "pop_growth_mean",
label = "Moyenne de la croissance de la population",
value = 1.1,
min = 0, max = Inf, step = 0.01),
numericInput(inputId = "pop_growth_se",
label = "Erreur-type de la croissance de la population",
value = 0.01,
min = 0, max = Inf, step = 0.01),
matrixInput(inputId = "pop_growth_mat_expert",
value = matrix(data = eli_pop_growth, nrow = 4, ncol = 5,
dimnames = list(c("#1", "#2", "#3", "#4"),
c("Poids", "Min", "Best", "Max", "% IC" )),
byrow = TRUE),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
actionButton(inputId = "pop_growth_run_expert", label = "Utiliser valeurs experts"),
## Input trend: radio buttons
{fluidRow(
# Trend
column(6,
radioButtons(inputId = "pop_trend",
label = "Tendance",
choices = c("Croissance" = "growth",
"Stable" = "stable",
"Dclin" = "decline")),
),
# Strength of trend
column(6,
radioButtons(inputId = "pop_trend_strength",
label = "Force",
choices = c("Faible" = "weak",
"Moyen" = "average",
"Fort" = "strong")),
)}, # close wellPanel
)}, # close conditional panel
)}, # end column "mortalite"
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
##~~~~~~~~~~~~~~~~~~~~~~~~~
## 4. Carrying capacity
##~~~~~~~~~~~~~~~~~~~~~~~~~
{column(width = 3,
tags$style(HTML('#button_carrying_cap{background-color:#C2C8D3}')),
actionButton(inputId = "button_carrying_cap", width = '100%',
label = tags$span("Capacit de charge", style = "font-weight: bold; font-size: 18px;")
),
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
{conditionalPanel("output.hide_carrying_cap",
br(),
{wellPanel(style = "background:#FFF8DC",
span(textOutput(outputId = "carrying_cap_unit_info"), style="font-size:16px"),
)}, # close wellPanel 1
{wellPanel(style = "background:#F0F8FF",
radioButtons(inputId = "carrying_cap_input_type",
label = "Type de saisie",
choices = c("Valeurs" = "val", "Elicitation d'expert" = "eli_exp")),
numericInput(inputId = "carrying_capacity",
label = "Capacit de charge",
value = 500,
min = 0, max = Inf, step = 100),
matrixInput(inputId = "carrying_cap_mat_expert",
value = matrix(data = eli_carrying_cap, nrow = 4, ncol = 5,
dimnames = list(c("#1", "#2", "#3", "#4"),
c("Poids", "Min", "Best", "Max", "% IC" )),
byrow = TRUE),
class = "numeric",
rows = list(names = TRUE),
cols = list(names = TRUE)),
actionButton(inputId = "carrying_cap_run_expert", label = "Utiliser valeurs experts"),
)}, # close wellPanel 2
)}, # close conditional panel
)}, # end column "fatalities"
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
)}, # # End wellPanel
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
## Side Panel : Parameter information
{sidebarLayout(
{sidebarPanel(

thierrychambert
committed
p("Valeurs utilises", style="font-size:28px"),
# Mortalites annuelles
{wellPanel(style = "background:#DCDCDC",
p("Mortalits annuelles", style="font-size:20px; font-weight: bold"),
span(textOutput(outputId = "fatalities_mean_info"), style="font-size:16px"),
span(textOutput(outputId = "fatalities_se_info"), style="font-size:16px"),
)},
# Taille de population
{wellPanel(style = "background:#DCDCDC",
p("Taille de la population", style="font-size:20px; font-weight: bold"),
shiny::tags$u(textOutput(outputId = "pop_size_unit_info"), style="font-size:16px"),
p(""),
span(textOutput(outputId = "pop_size_mean_info"), style="font-size:16px"),
span(textOutput(outputId = "pop_size_se_info"), style="font-size:16px"),
# Tendance de la population
{wellPanel(style = "background:#DCDCDC",
p("Tendance de la population", style="font-size:20px; font-weight: bold"),
span(textOutput(outputId = "pop_growth_mean_info"), style="font-size:16px"),
span(textOutput(outputId = "pop_growth_se_info"), style="font-size:16px"),
)},
# Capacite de charge
{wellPanel(style = "background:#DCDCDC",
p("Capacit de charge", style="font-size:20px; font-weight: bold"),
span(textOutput(outputId = "carrying_capacity_info"), style="font-size:16px"),
)},
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tabPanel(title = "Distribution paramtres",
br(),
hr(),
#h3("Mortalites annuelles", align = "center"),
span(textOutput(outputId = "title_distri_plot"), style="font-size:24px; font-weight:bold"),
plotOutput(outputId = "distri_plot"),
br(),
numericInput(inputId = "nsim",
label = "Nombre de simulations",

thierrychambert
committed
value = 10, min = 0, max = Inf, step = 10),
choices = c("Taux de mortalits (h) constant" = "h",
"Nombre de mortalits (M) constant" = "M")),
br(),
actionButton(inputId = "run", label = "Lancer l'analyse"),
hr(),
span(textOutput("title_impact_result"), align = "left", style = "font-weight: bold; font-size: 18px;"),
br(),
strong(span(textOutput("impact_text"), style="color:blue; font-size:18px", align = "left")),
strong(span(tableOutput("impact_table"), style="color:blue; font-size:18px", align = "left")),
tags$h4(textOutput("title_impact_plot"), align = "center"),
plotOutput("impact_plot", width = "100%", height = "550px"),
tags$h4(textOutput("title_traj_plot"), align = "center"),
plotOutput("traj_plot", width = "100%", height = "550px")
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")),
h4("Nombre de parcs"),
value = 1, min = 0, max = Inf, step = 1),
)} # End mainPanel
)} # sidebarLayout
)} # FluidPage
# End UI #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###