Skip to content

Commit

Permalink
Starting to add the Glossary to the protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Jung committed Mar 21, 2024
1 parent c085c7f commit 62be5b7
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 22 deletions.
2 changes: 2 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ app_server <- function(input, output, session) {

# News
mod_News_server("News_1")
mod_Glossary_server("Glossary_1")
# Import/Export
mod_Import_server("Import_1")
mod_Export_server("Export_1", results)

# Automatically stop a Shiny app when closing the browser tab
# NOTE: Disabled this as it seems to stop the instance across browsers
# session$onSessionEnded(stopApp)
}

6 changes: 6 additions & 0 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ app_ui <- function(request) {
tabName = "News",
icon = shiny::icon("newspaper")
),
bs4Dash::menuItem(
"Glossary",
tabName = "Glossary",
icon = shiny::icon("book")
),
bs4Dash::menuItem(
"Issues and Feedback",
href = "https://github.com/iiasa/ODPSCP/issues",
Expand Down Expand Up @@ -151,6 +156,7 @@ app_ui <- function(request) {
mod_Prioritization_ui("Prioritization_1"),
# News
mod_News_ui("News_1"),
mod_Glossary_ui("Glossary_1"),
# Import
mod_Import_ui("Import_1"),
mod_Export_ui("Export_1")
Expand Down
7 changes: 4 additions & 3 deletions R/mod_Design.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ mod_Design_ui <- function(id){
solidHeader = TRUE,
status = "secondary",
collapsible = FALSE,
shiny::p('Most SCP applications are applied rather than curiosity driven.
Here we ask whether the pathway to impact and
influencing outcomes is clear.'),
shiny::p('Most SCP applications are applied rather than curiosity driven. However an applied
focus does not necessarily mean that the work will be implemented and the pathway to
impact is clear. A theory of change is a apriori process that maps the relationship between
a long-term goal of a planning objective and the necessary steps required to implement it.'),
shiny::textAreaInput(inputId = ns("theoryofchange"), label = "",
placeholder = 'Describe the theory of change if there is any.',
height = "45px", width = "100%", resize = "vertical")
Expand Down
67 changes: 67 additions & 0 deletions R/mod_Glossary.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#' Glossary UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
#' @importFrom bs4Dash insertTab tabItem tabItems
#' @importFrom shiny actionButton tabsetPanel column
mod_Glossary_ui <- function(id){
ns <- NS(id)

bs4Dash::tabItem(
tabName = "Glossary",
shiny::fluidPage(
shiny::fluidRow(
shiny::column(width = 2),
shiny::column(width = 12,
bs4Dash::tabsetPanel(
id = ns("Glossary"),
type = "pills",
vertical = FALSE,
selected = "Glossary",
# News panel
shiny::tabPanel(
title = "Glossary",
shiny::br(),
bs4Dash::box(
title = "Glossary",
status = "primary",
solidHeader = TRUE,
collapsed = FALSE,
width = 12,
DT::dataTableOutput('glossary_table')
)
)
)
)
)
) # End fluidpage
) # End of tabItem
}

#' Glossary Server Functions
#'
#' @noRd
mod_Glossary_server <- function(id){
shiny::moduleServer( id, function(input, output, session){
ns <- session$ns

# Get the protocol for print
ppath <- system.file("glossary_table.csv",
package = "ODPSCP",
mustWork = TRUE)
output$glossary_table <- DT::renderDataTable(
read.csv(ppath)
)
})
}

## To be copied in the UI
# mod_Glossary_ui("Glossary_1")

## To be copied in the server
# mod_Glossary_server("Glossary_1")
7 changes: 4 additions & 3 deletions R/mod_Prioritization.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mod_Prioritization_ui <- function(id){
label = "Used software",
choices = c("","Zonation","Marxan",
"prioritizr","prioriactions",
"RestOptr","oppr",
"RestOptr","oppr", "ConsNet",
"CAPTAIN","ROOT", "C-PLAN",
"Custom","Other"),
options = list(
Expand All @@ -75,8 +75,9 @@ mod_Prioritization_ui <- function(id){
ns = ns,
shiny::p("Enter a version number of the used software.
Also provide any other information related to software
(for example if a specific solver was used for integer programming)."),
shiny::textAreaInput(inputId = ns("versionnr"), label = "Provide a version number and other information related to software.",
(for example if a specific solver was used for mathematical programming such as Gurobi or Symphony)."),
shiny::textAreaInput(inputId = ns("versionnr"),
label = "Provide a version number and other information related to the software.",
placeholder = 'Enter free text here.',
height = "45px", width = "100%", resize = "none")
),
Expand Down
36 changes: 25 additions & 11 deletions R/mod_Specification.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,39 @@ mod_Specification_ui <- function(id){
),
shiny::br(),
bs4Dash::box(
title = "Planning unit costs",
title = "Planning unit costs or penalities",
closable = FALSE,
width = 12,
solidHeader = TRUE,
status = "secondary",
collapsible = FALSE,
shiny::p("The decision where to allocate conservation efforts can to a large degree be determined
by economic, biophysical or socio-economic constraints. One way of including those in planning
studies is to threat them as a cost or penality, thus penalizing the selection of any outcomes
with too high costs. Typical are for example the costs of land acquistion in area-based planning."),
shinyWidgets::pickerInput(
inputId = ns("pu_checkcosts"),
label = "Where there any costs of selecting a planning unit?",
choices = c("No", "Area only", "Yes"),
multiple = FALSE
label = "Where there any costs or penalities for selecting a planning unit? Select one or multiple.",
choices = c(
c("Area only",
"Biophysical proxy",
"Socioeconomic proxy",
"Implementation cost",
"Acquisition cost",
"Opportunity cost",
"Management cost",
"Logistics cost",
"Sampling effort",
"Other")
),
options = list(`actions-box` = TRUE),
multiple = TRUE
),
shiny::conditionalPanel(
condition = "input.pu_checkcosts == 'Yes'",
ns = ns,
shiny::textAreaInput(inputId = ns("pu_costs"), label = "Describe process of creating costs",
placeholder = 'Provide some detail on how costs were defined or created.',
height = "45px", width = "100%", resize = "none")
)
shiny::br(),
# Any other cost description?
shiny::textAreaInput(inputId = ns("pu_costs"), label = "Describe process of creating costs",
placeholder = 'Provide some detail on how costs were defined or created.',
height = "45px", width = "100%", resize = "none")
)
)
) # End column
Expand Down
3 changes: 2 additions & 1 deletion dev/02_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ golem::add_module(name = "Context", with_test = FALSE) # Name of the module
golem::add_module(name = "Planning", with_test = FALSE) # Name of the module

golem::add_module(name = "News", with_test = FALSE) # Name of the module
golem::add_module(name = "Glossary", with_test = FALSE) # Name of the module
golem::add_module(name = "Import", with_test = FALSE) # Name of the module
golem::add_module(name = "Export", with_test = FALSE) # Name of the module

Expand All @@ -47,7 +48,7 @@ golem::add_utils("format_protocol", with_test = FALSE) # Text external

## Add internal datasets ----
## If you have data in your package
# usethis::use_data_raw(name = "my_dataset", open = FALSE)
# usethis::use_data_raw(name = "glossary_table", open = FALSE)

## Tests ----
## Add one line by test you want to create
Expand Down
15 changes: 11 additions & 4 deletions inst/01_protocol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,20 @@ specification:
render-nr: 3
render-id: 'pu_checkcosts'
render-group: 'planningunits'
question: 'Was the decision of selecting planning units driven by some costs?'
question: 'Where there any costs of selecting a planning unit? Select one or multiple.'
description: 'Describe the grain of planning units if applicable.'
fieldtype: 'dropdown'
fieldtype: 'multiplechoice'
options:
- None
- Area only
- Yes
- Biophysical proxy
- Socioeconomic proxy
- Implementation cost
- Acquisition cost
- Opportunity cost
- Management cost
- Logistics cost
- Sampling effort
- Other
fieldtype_conditional_render-id: 'pu_costs'
fieldtype_conditional: 'textbox'
mandatory: true
Expand Down
14 changes: 14 additions & 0 deletions inst/glossary_table.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Term,Abbreviation,Definition,Reference
Planning unit,PU,The spatial- or spatial-temporal geographical unit over which a decision is made. Typical examples include a grid cell or vector shape (such as farmland or country borders).,Authors
Target,T,An explicit parameter quantifying the desired representation of a given feature in the prioritization. ,"Adapted from Margules, C. R., & Sarkar, S. (2007). Systematic conservation planning. Cambridge University Press. "
Representation,,Can be measured as the fraction of features that meet their set of targets. Or alternatively if targets have not been formulated as the fraction of the total amount of a feature covered by a solution.,"Adapted from Margules, C. R., & Sarkar, S. (2007). Systematic conservation planning. Cambridge University Press. "
Features,F,A set of quantitative datasets included in the planning process and over which priorities should be identified. Examples include for example spatial[-temporal] estimates of species distribution or abundance.,Authors
Systematic conservation planning,SCP,"Systematic conservation planning consists of the use of protocols to identify areas or actions that should have priority for the allocation of [scarce] management resources and separate them from processes which threaten their persistence. Systematic conservation planning is usually implemented with software tools using digital georeferenced data sets and area-selection algorithms. It is a structured step-wise approach to mapping conservation area networks, with feedback, revision and reiteration, where needed, at any stage.","Adapted from Margules, C. R., & Sarkar, S. (2007). Systematic conservation planning. Cambridge University Press. "
Spatial prioritization,,Synonym for the application of an area- or action based algorithm for identifying priority areas. Distinct SCP as it captures only the statistical part of any planning exercise.,Authors
Solution,s,A single output from a spatial prioritization process.,Authors
Cost,c,A [spatial-explicit] estimate of the cost of selecting a given area or action as a priority.,Authors
Complementarity,,Measure of the contribution of an area in a planning region towards the full complement of [biodiversity] features. A set of complementary planning units in a solution increase the likelihood for a conservation network [or action[ to be comprehensive.,"Adapted from Margules, C. R., & Sarkar, S. (2007). Systematic conservation planning. Cambridge University Press. And Wilson, K.A., Cabeza, M. and Klein, C.J., 2009. Fundamental concepts of spatial conservation prioritization. Spatial conservation prioritization: Quantitative methods and computational tools, pp.16-27."
Comprehensiveness,,Defined as a set of priority areas that include at a minimum a portion of every feature used in the planning.,"Wilson, K.A., Cabeza, M. and Klein, C.J., 2009. Fundamental concepts of spatial conservation prioritization. Spatial conservation prioritization: Quantitative methods and computational tools, pp.16-27."
Cost-efficiency,,"A cost-efficient network of priority areas is one that is comprehensive, representative, and/or adequate for the least possible cost. Cost-efficiency is important because it facilitates future expansion of a network of priority areas through the prudent use of conservation resources and is more likely to be defensible in light of competing interests","Wilson, K.A., Cabeza, M. and Klein, C.J., 2009. Fundamental concepts of spatial conservation prioritization. Spatial conservation prioritization: Quantitative methods and computational tools, pp.16-27."
Irreplaceability,,Measures the value of the inclusion of a planning unit in a solution relative to specified targets and other constraints.,"Wilson, K.A., Cabeza, M. and Klein, C.J., 2009. Fundamental concepts of spatial conservation prioritization. Spatial conservation prioritization: Quantitative methods and computational tools, pp.16-27."
Constraint,,A constraint placed on whether or to what extent a given area can be selected as priority.,Authors

0 comments on commit 62be5b7

Please sign in to comment.