Package 'sdmEvalToolUI'

Title: SDM Evaluation Tool Shiny UI
Description: The goal of sdmEvalToolUI is to implement Shiny functionality according to the SDM Evaluation Tool requirements to evaluate materials.
Authors: Peter Solymos [aut, cre] (ORCID: <https://orcid.org/0000-0001-7337-1740>), Steffi LaZerte [aut] (ORCID: <https://orcid.org/0000-0002-7690-8360>), Analythium Solutions Inc. [cph], His Majesty the King in Right of Canada as represented by the Minister of the Environment [cph] (Copyright holder for default evaluation/drill down questions.), Biodiversity Pathways [cph] (Copyright holder for glossary.csv, and default evaluation/drill down questions.), Alberta Biodiversity Monitoring Institute [cph] (Copyright holder for glossary.csv, and default evaluation/drill down questions.)
Maintainer: Peter Solymos <[email protected]>
License: Apache License 2.0
Version: 0.0.1
Built: 2026-10-01 07:40:24 UTC
Source: https://github.com/LandSciTech/sdmEvaluationTool

Help Index


Add Layers control to map

Description

Add Layers control to map

Usage

add_control(map, groups = character(0))

Arguments

map

Leaflet map

groups

Character vector. Layers or Group names to add to the control. Subunits are included by default. Only existing layers are included.

Value

Leaflet map with layer control buttons

Examples

# No subunits
r <- template_spatial_prep()
base_map() |>
  add_raster(r, layer = "mean", palette = "viridis", name = "Mean") |>
  add_control(groups = "Mean")

# With subunits
if(have_data()) {
  r <- template_spatial_prep()
  s <- deployment_subunits_prep("deployment1")
  base_map() |>
    add_raster(r, layer = "mean", palette = "viridis", name = "Mean") |>
    add_subunits(s) |>
    add_control(groups = "Mean")
}

Add point markers to Leaflet map

Description

Add point markers to Leaflet map

Usage

add_markers(
  map,
  data = leaflet::getMapData(map),
  colour_by = "layers",
  layer_by = "layers"
)

Arguments

map

Leaflet map object.

data

Spatial data with markers to plot (defaults to data in the map object).

colour_by

Character. Column to use when colouring points.

layer_by

Character. Column to use to group points into layers (for add_control()).

Value

Leaflet map.

Examples

base_map() |>
  add_markers(data = test_points()) |>
  add_control(groups = c("present", "absent")) # From 'layers' column

Add raster as image layer to leaflet map

Description

Note that raster layers are attached to a new map pane with a defined z-index. This is so we can be sure the raster is above the map tiles (z-index 200, see base_map()), and yet below the subunits (default z-index of 400).

Usage

add_raster(
  map,
  raster,
  layer,
  name,
  palette,
  opacity = 0.8,
  add_legend = TRUE,
  min_0 = TRUE
)

Arguments

map

Leaflet map

raster

Terra raster to add

layer

Layer in raster to add

name

Name of leaflet layer (for controls and ids)

palette

Character. Colour palette to use

opacity

Numeric. Opacity of raster layer

add_legend

Logical. Whether or not to add a legend.

min_0

Logical. Whether to force the legend to start at zero.

Value

Leaflet map

Examples

r <- template_spatial_prep()
base_map() |>
  add_raster(r, layer = "mean", palette = "viridis", name = "Mean")

Add selected point markers to Leaflet map

Description

Very similar to add_markers() but colours according to type column which defines the selections and no option to add to controls.

Usage

add_selected_markers(map, data = leaflet::getMapData(map), colour_by = "type")

Arguments

map

Leaflet map object.

data

Spatial data with markers to plot (defaults to data in the map object).

colour_by

Character. Column to use when colouring points.

Value

Leaflet map.

Examples

base_map() |>
  add_selected_markers(data = test_points())

Add selected subunits to Leaflet map

Description

Similar to add_subunits() but colours subunits by fill colour and selection type.

Usage

add_selected_subunits(
  map,
  subunits = NULL,
  colour_by = "type",
  opacity = 0.8,
  fill_opacity = 0.2
)

Arguments

map

Leaflet map object.

subunits

Spatial Data Frame. Subunits

colour_by

Vector. Column to fill by (must be a factor with levels to get the correct legend).

opacity, fill_opacity

Numeric. Opacity.

Examples

subunits <- deployment_subunits_prep("deployment1") |>
  dplyr::mutate(
    type = c(rep("Very biased", 10), rep("Moderately biased", 10), rep(NA, 114)),
    type = factor(type)
  )

base_map() |>
  add_selected_subunits(subunits)

Add subunits to Leaflet map

Description

Add subunits to Leaflet map

Usage

add_subunits(map, subunits = NULL, colour_by = "subunit_id", opacity = 0.8)

Arguments

map

Leaflet map object.

subunits

Spatial Data Frame. Subunits

colour_by

Vector. Column to fill by

opacity

Numeric. Opacity.

Examples

subunits <- deployment_subunits_prep("deployment1")

base_map() |>
  add_subunits(subunits)

Evaluation answers in the affirmative

Description

Used to determine which parts should be displayed

Usage

affirmative(type = "standard")

Arguments

type

Character. "standard" (currently for ordinal inputs), or "spatial"

Value

Character vector of affirmative answers

Examples

affirmative()
affirmative("spatial")

Get all materials available

Description

Get all materials available

Usage

app_materials()

Value

Data frame of all materials available

Examples

app_materials()

Get Users details

Description

Get Users details

Usage

app_users()

Value

Data frame of user details

Examples

app_users()

Base Map with Provider Tiles

Description

Create the base Leaflet map with standard tiles, selection draw toolbar and erase selection button. Also includes and custom Javascripts, here one for marking which layers are visible for use in selections filtering (see mod_utils_map_selections_server()).

Usage

base_map(ns = identity)

Arguments

ns

Namespace. Required for spatial selections.

Examples

base_map()

SDM tool versions of bslib functions

Description

Usage

sdm_card(..., class = "p-0", full_screen = TRUE, min_height = 400)

sdm_card_header(..., class = "bg-sdm")

sdm_nav_panel(title, ..., class = "sdm-tab-pane")

sdm_layout_sidebar(..., gap = 0, border = FALSE)

Arguments

...

See bslib function

class

Character vector. HTML classes to add to the card.

full_screen

Logical. Option to make card full screen.

min_height

Numeric. Minimum card height.

title

Character. Nav panel title.

gap

Numeric. Vertical gap between sidebar elements.

border

Logical. Whether or not to add a border.

Value

bslib function output


Compare number of questions

Description

Compares the number of questions from those evaluated (q2) to those calculated from the question data (q1). Questions from evaluated (q2) may be NA if evaluations haven't been finished. Will error if values don't match (ignoring NAs).

Usage

check_q_mismatch(q1, q2)

Arguments

q1

Vector of Integers. Number of questions calculated from Question data (total questions available).

q2

Vector of Integers. Number of questions evaluated.

Value

invisible or error if there is a mismatch.

Examples

check_q_mismatch(c(1, 1, 2, 10, 6), c(1, 1, 2, 10, 6))
check_q_mismatch(c(10, 7, 1), c(10, NA, NA))
# check_q_mismatch(c(10, 11, 1), c(10, 10, NA)) # Error

Convert coordinates to polygon

Description

For use when drawing selections.

Usage

coords_to_poly(geometry)

Arguments

geometry

From drawing selections.

Value

Sf polygon


db connect with check

Description

Put the checks here rather than sdmEvalToolCore to avoid Shiny dependency in core package.

Usage

db_connect_check(dbname = NULL, ...)

Arguments

dbname

DB name.

...

Arguments passed to DBI::dbConnect().

Value

A database connection.


Create a Leaflet Map of Subunits

Description

Create a Leaflet Map of Subunits

Usage

deployment_subunits_map(subunits, ns = identity)

Arguments

subunits

Spatial Data frame. Deployment subunits.

ns

Namespace.

Value

A leaflet map object

Examples

s <- deployment_subunits_prep("deployment1")
deployment_subunits_map(s)

Prepare Deployment Subunits

Description

Subunits are used by multiple mapping components for a deployment.

Usage

deployment_subunits_prep(deployment_id)

Arguments

deployment_id

Character. Deployment ID

Value

Subunits polygons

Examples

deployment_subunits_prep(deployment_id = "deployment1")

Calculate number of answered questions

Description

Summarizes evaluation data to count total questions and completed questions.

Usage

evals_answered(eval)

Arguments

eval

Data frame. Evaluation data with response column

Details

This is used by the 'overview'/'summary'/'index' page.

Value

Data frame with columns: n_q (total questions), n_q_complete (completed questions)

Examples

eval_data <- evals_extract(test_evaluation_body())
evals_answered(eval_data)

eval_data <- evals_extract(test_evaluation_body(component_id = "model_fit_a"))
evals_answered(eval_data)

eval_data <- evals_extract(test_evaluation_body(component_id = "model_fit_b"))
evals_answered(eval_data)

Get Evaluation Details for User

Description

Retrieves evaluation details for a specific user based on their role. For modelers, shows all evaluations across users for their deployments. For evaluators, shows only their own evaluations. Returns a data frame with deployment, model, species, component, and completion information.

Usage

evals_details(user_id, user_role)

Arguments

user_id

Character string. User identifier

user_role

Character string. User role ("modeler" or "evaluator")

Details

This is used by the 'overview'/'summary'/'index' page.

Value

Data frame with columns:

  • deployment_model_name

  • evaluation_create_user_name

  • deployment_name

  • model_name

  • species_display

  • component_name

  • completed

  • started

  • n_q_display

  • n_q

  • n_q_complete

Examples

evals_details("testuser", "evaluator")
evals_details("testuser", "modeler")

Extract evaluations from JSON

Description

Parses JSON-formatted evaluation body into a data frame. Opposite of response_to_json().

Usage

evals_extract(json)

Arguments

json

Character. JSON-formatted evaluation data

Value

Data frame with evaluation information

Examples

evals_extract(test_evaluation_body())

Convert questions to input list structure

Description

For comparing questions to Shiny input answers, convert the questions to the same input list structure as returned in the Shiny app.

Usage

evals_list(questions)

Arguments

questions

Data frame. Data frame of questions; output of prep_questions().

Value

List which imitates a Shiny input object

Examples

q <- prep_questions(
  "observations",
  "deployment1",
  "bam_v5_can71",
  "BBWA",
  "testuser"
)
evals_list(q)

q <- prep_questions(
  "model_summary",
  "deployment1",
  "bam_v5_can71",
  "BBWA",
  "testuser"
)
evals_list(q)

Create a Reactable Overview table

Description

Creates reactable table displaying evaluation progress for either modelers or evaluators. The table shows deployment-model combinations, species, components, and their completion status.

Usage

evals_table(tbl, user_role)

Arguments

tbl

Data frame. Evaluation details from evals_details()

user_role

Character. User role ("modeler", or "evaluator")

Value

A reactable table object

Examples

tbl <- evals_details("testuser", "evaluator")
evals_table(tbl, "evaluator")

Extract feature ids

Description

Extract feature ids

Usage

feature_ids(features)

Arguments

features

The input for the draw all features (⁠input${map}_draw_all_features⁠).

Value

Numeric vector of leaflet ids


Low-level function to read in questions.

Description

If deployment doesn't exist, uses sdmEvalToolCore::default_questions().

Usage

fetch_questions(deployment_id, component_id)

Arguments

deployment_id

Character. Deployment ID

component_id

Character. Component ID

Value

Data frame of questions.

Examples

# Use default questions if deployment doesn't exist
fetch_questions("No deployment", "observations")

if(have_data()) {
  fetch_questions("deployment1", "observations")
}

Format species display names

Description

Format species display names

Usage

fmt_species(df)

Arguments

df

Data frame to format. Must contain at least species name in French or English as well as scientific name.

Value

Formatted species display names.


Format time nicely for humans

Description

Format time nicely for humans

Usage

fmt_time(time)

Arguments

time

POSIXct time

Value

Character. Nicely formated date

Examples

fmt_time(Sys.time())
fmt_time(as.POSIXct("2026-02-01 16:02"))

Get Material Settings

Description

Get Material Settings

Usage

get_material_settings(x)

Arguments

x

Object.

Value

The value of the material settings attribute


Have local data?

Description

Checks whether the user has local data available for this tool. Used for examples (must be exported).

Usage

have_data()

Value

TRUE/FALSE

Examples

have_data()

Loosely test if identical

Description

Used in mod_utils_evaluations_server() to loosely determine if evaluations are identical between saved and inputs (to determine if the unsaved notice should be used).

Usage

identical_loose(i1, i2)

Arguments

i1

Character

i2

Character

Value

Logical


Helper function to format Shiny Input names as Question Values

Description

Helper function to format Shiny Input names as Question Values

Usage

input_to_value(i)

Arguments

i

Character vector of Input names

Value

Character string of Shiny Inputs names formatted as Question values

Examples

input_to_value("Strongly_Agree")

Return the app language

Description

Return the app language

Usage

lang()

Value

Character. Either "english" or "french"

Examples

lang()

Check if a group exists in map

Description

Note: this only works for Leaflet maps, NOT Leaflet Proxies. For example, this is why mod_comp_predictor_raster family of functions are a bit convoluted when it calls to adding layers and controls (because add_controls() only adds layers which are detected with this function).

Usage

map_has_group(map, group)

Arguments

map

Leaflet Map (not Leaflet Proxy).

group

Character Vector. Groups to check for.

Details

This may be slightly fragile if the list structure of the leaflet objects change.

Value

Logical. True if detected, false otherwise.


Create reactive vals and keep updated

Description

Tracks interactive inputs from map selections. Depending on the origin, namespaced if necessary.

Usage

map_reactive_vals(
  input,
  map,
  x = c("draw_all_features", "draw_new_feature", "draw_stop", "marker_click",
    "shape_click"),
  js_x = c("clear_selection", "layers_visible")
)

Arguments

input

Shiny input object.

map

Character. Map name.

x

Character vector. Names of interactive inputs which are namespaced to the map, so must be namespaced here.

js_x

Character vector. Names of Javascript created interactive inputs which do not need to be namespaced.

Details

Used at the component-level for those using spatial selections.

Value

A reactiveValues() list, as well as having the side effect of creating shiny::observe() for each value in the list to be independently updated.


Deployment Subunits component Server

Description

Deployment Subunits component Server

Usage

mod_comp_deployment_subunits_server(
  id = "comp_summary",
  parent_id,
  deployment_id,
  model_id,
  species_id,
  spatial_selection,
  spatial_ids,
  map_views
)

Arguments

id

Module ID

parent_id

Parent tab ID (used to identify which tab is active)

deployment_id

Deployment ID

model_id

Model ID

species_id

Species ID

spatial_selection

Spatial selection

spatial_ids

Spatial IDs

map_views

List. List of reactiveVals active_tab, set_by and view (list with zoom and lat/lon).

Value

Module server function


Deployment Subunits Component UI

Description

Deployment Subunits Component UI

Usage

mod_comp_deployment_subunits_ui(id = "comp_summary", header = "Comfort zones")

Arguments

id

Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_deployment_subunits_ui()

Model Fit Component Server

Description

Model Fit Component Server

Usage

mod_comp_model_fit_server(id = "comp_model_fit", model_id, species_id)

Arguments

id

Module ID

model_id

Model ID

species_id

Species ID

Value

Module server function


Model Fit Component UI

Description

Model Fit Component UI

Usage

mod_comp_model_fit_ui(id = "comp_model_fit", header = "Model Fit")

Arguments

id

Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_model_fit_ui()

Model Summary component Server

Description

Model Summary component Server

Usage

mod_comp_model_summary_server(id = "comp_model_summary", model_id, species_id)

Arguments

id

Module ID

model_id

Model ID

species_id

Species ID

Value

Module server function


Model Summary Component UI

Description

Model Summary Component UI

Usage

mod_comp_model_summary_ui(id = "comp_model_summary", header = "Model Summary")

Arguments

id

Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_model_summary_ui()

Observations Chart Component Server

Description

Observations Chart Component Server

Usage

mod_comp_obs_chart_server(id = "comp_obs_chart", model_id, species_id)

Arguments

id

Module ID

model_id

Model ID

species_id

Species ID

Value

Module server function


Observations Chart Component UI

Description

Observations Chart Component UI

Usage

mod_comp_obs_chart_ui(id = "comp_obs_chart", header = "Observation Charts")

Arguments

id

Character. Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_obs_chart_ui()

Observations component Server

Description

Observations component Server

Usage

mod_comp_observations_server(
  id = "comp_observations",
  parent_id,
  deployment_id,
  model_id,
  species_id,
  spatial_selection,
  spatial_ids,
  map_views
)

Arguments

id

Module ID

parent_id

Parent tab ID (used to identify which tab is active)

deployment_id

Deployment ID. Required for subunits.

model_id

Model ID

species_id

Species ID

spatial_selection

Spatial selection

spatial_ids

Spatial IDs

map_views

List. List of reactiveVals active_tab, set_by and view (list with zoom and lat/lon).

Value

Module server function


Observations Component UI

Description

Observations Component UI

Usage

mod_comp_observations_ui(
  id = "comp_observations",
  header = "Map of Observations"
)

Arguments

id

Character. Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_observations_ui()

Predictor Metadata component Server

Description

Predictor Metadata component Server

Usage

mod_comp_predictor_metadata_server(id = "comp_predictor_metadata", model_id)

Arguments

id

Module ID

model_id

Model ID

Value

Module server function


Predictor Metadata Component UI

Description

Predictor Metadata Component UI

Usage

mod_comp_predictor_metadata_ui(
  id = "comp_predictor_metadata",
  height = "40%",
  header = "Predictor Metadata"
)

Arguments

id

Shiny module ID

height

Height

header

Header

Value

Shiny UI

Examples

mod_comp_predictor_metadata_ui()

Predictor Raster component Server

Description

Predictor Raster component Server

Usage

mod_comp_predictor_raster_server(
  id = "comp_predictor_raster",
  parent_id,
  deployment_id,
  model_id,
  map_views
)

Arguments

id

Module ID

parent_id

Parent tab ID (used to identify which tab is active)

deployment_id

Deployment ID. Required for subunits.

model_id

Model ID

map_views

List. List of reactiveVals active_tab, set_by and view (list with zoom and lat/lon).

Value

Module server function


Predictor Raster Component UI

Description

Predictor Raster Component UI

Usage

mod_comp_predictor_raster_ui(
  id = "comp_predictor_raster",
  height = NULL,
  header = "Predictor Raster"
)

Arguments

id

Shiny module ID

height

Height

header

Header

Value

Shiny UI

Examples

mod_comp_predictor_raster_ui()

Spatial Prediction component Server

Description

Spatial Prediction component Server

Usage

mod_comp_spatial_prediction_server(
  id = "comp_spatial_prediction",
  parent_id,
  deployment_id,
  model_id,
  species_id,
  spatial_selection,
  spatial_ids,
  map_views
)

Arguments

id

Module ID

parent_id

Parent tab ID (used to identify which tab is active)

deployment_id

Deployment ID. Required for subunits.

model_id

Model ID

species_id

Species ID

spatial_selection

Spatial selection. Required for spatial evaluations

spatial_ids

Spatial IDs. Required for spatial evaluations.

map_views

List. List of reactiveVals active_tab, set_by and view (list with zoom and lat/lon).

Value

Module server function


Spatial Prediction Component UI

Description

Spatial Prediction Component UI

Usage

mod_comp_spatial_prediction_ui(
  id = "comp_spatial_prediction",
  header = "Predictions"
)

Arguments

id

Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_spatial_prediction_ui()

Template component Server

Description

Template component Server

Usage

mod_comp_template_server(id = "comp_template", model_id, species_id)

Arguments

id

Module ID

model_id

Model ID

species_id

Species ID

Value

Module server function


Template Spatial component Server

Description

Template Spatial component Server

Usage

mod_comp_template_spatial_server(
  id = "comp_template_spatial",
  parent_id,
  deployment_id,
  model_id,
  species_id,
  spatial_selection,
  spatial_ids,
  map_views
)

Arguments

id

Module ID

parent_id

ID of the parent module, corresponds to the tab.

deployment_id

Deployment ID. Required for subunits.

model_id

Model ID

species_id

Species ID

spatial_selection

Spatial selection. Required for spatial evaluations.

spatial_ids

Spatial IDs. Required for spatial evaluations.

map_views

List. List of reactiveVals active_tab, set_by and view (list with zoom and lat/lon).

Value

Module server function


Template Spatial Component UI

Description

Template Spatial Component UI

Usage

mod_comp_template_spatial_ui(
  id = "comp_template_spatial",
  header = "Template Spatial"
)

Arguments

id

Character. Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_template_spatial_ui()

Template Component UI

Description

Template Component UI

Usage

mod_comp_template_ui(id = "comp_template", header = "Template")

Arguments

id

Shiny module ID

header

Header

Value

Shiny UI

Examples

mod_comp_template_ui()

Model Page Server

Description

Model Page Server

Usage

mod_page_model_server(id = "model", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts list (see sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Model Page UI

Description

Model Page UI

Usage

mod_page_model_ui(id, title, review_width = NULL)

Arguments

id

Shiny module ID

title

Page title

review_width

Review width

Value

Shiny UI

Examples

mod_page_model_ui("id", "title")

Observations Page Server

Description

Observations Page Server

Usage

mod_page_observations_server(id = "observations", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts, map_views. See sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Observations Page UI

Description

Observations Page UI

Usage

mod_page_observations_ui(id, title, review_width = NULL)

Arguments

id

Shiny module ID

title

Page title

review_width

Character. Width of the review sidebar in percentage of the screen

Value

Shiny UI

Examples

mod_page_observations_ui("id", "title")

Overview Page Server

Description

Overview Page Server

Usage

mod_page_overview_server(id = "overview", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts list (see sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Overview Page UI

Description

Overview Page UI

Usage

mod_page_overview_ui(id, title)

Arguments

id

Shiny module ID

title

Page title

Value

Shiny UI

Examples

mod_page_overview_ui("id", "title")

Predictions Page Server

Description

Predictions Page Server

Usage

mod_page_predictions_server(id = "predictions", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts, map_views. See sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Predictions Page UI

Description

Predictions Page UI

Usage

mod_page_predictions_ui(id, title, review_width = NULL)

Arguments

id

Shiny module ID

title

Page title

review_width

Review width

Value

Shiny UI

Examples

mod_page_predictions_ui("id", "title")

Predictors Page Server

Description

Predictors Page Server

Usage

mod_page_predictors_server(id = "predictors", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts, map_views. See sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Predictors Page UI

Description

Predictors Page UI

Usage

mod_page_predictors_ui(id, title, review_width = NULL)

Arguments

id

Shiny module ID

title

Page title

review_width

Review width

Value

Shiny UI

Examples

mod_page_predictors_ui("id", "title")

Summary Page Server

Description

Summary Page Server

Usage

mod_page_summary_server(id = "summary", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts, map_views. See sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Summary Page UI

Description

Summary Page UI

Usage

mod_page_summary_ui(id, title, review_width = NULL)

Arguments

id

Shiny module ID

title

Page title

review_width

Review width

Value

Shiny UI

Examples

mod_page_summary_ui("id", "title")

Template Page Server

Description

Template Page Server

Usage

mod_page_template_server(id = "template", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts list (see sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Template Page Server

Description

Template Page Server

Usage

mod_page_template_spatial_server(id = "template_spatial", ...)

Arguments

id

Shiny module ID. NOTE for pages this should match a value in the tabs argument of sdm_tool().f

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts, map_views. See sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Template Spatial Page UI

Description

Template Spatial Page UI

Usage

mod_page_template_spatial_ui(id, title, review_width = NULL)

Arguments

id

Shiny module ID

title

Page title

review_width

Review width

Value

Shiny UI

Examples

mod_page_template_spatial_ui("id", "title")

Template Page UI

Description

Template Page UI

Usage

mod_page_template_ui(id, title, review_width = NULL)

Arguments

id

Shiny module ID

title

Page title

review_width

Review width

Value

Shiny UI

Examples

mod_page_template_ui("id", "title")

Test Page Server

Description

Test Page Server

Usage

mod_page_test_server(id = "test", ...)

Arguments

id

Shiny module ID

...

Additional arguments passed via expand_dots including deployment_id, model_id, species_id, abandoned, unsaved, opts list (see sdm_tool() which programmatically calls all module pages.

Value

Server function for Shiny module


Test Page UI

Description

Test Page UI

Usage

mod_page_test_ui(id, review_width = "50%")

Arguments

id

Shiny module ID

review_width

Character. Width of the review sidebar in percentage.

Value

Shiny UI

Examples

mod_page_test_ui("id")

Utility Module 'Details' Server

Description

Used in sdm_tool() to create the Deployment Details left-hand sidebar.

Usage

mod_utils_details_server(id = "details", details)

Arguments

id

Shiny module ID

details

Data frame of details to display.

Value

Server function for Shiny module


Utility Module 'Details' UI

Description

Used in sdm_tool() to create the Deployment Details left-hand sidebar.

Usage

mod_utils_details_ui(id = "details")

Arguments

id

Shiny module ID

Value

Shiny UI

Examples

mod_utils_details_ui()

Utility Module 'Evaluations' Server

Description

Utility Module 'Evaluations' Server

Usage

mod_utils_evaluations_server(
  id = "evaluations",
  component_id,
  deployment_id,
  model_id,
  species_id,
  spatial_ids = reactive(NULL),
  opts,
  abandoned,
  unsaved
)

Arguments

id

Shiny module ID

component_id

Character. Component ID

deployment_id

Character. Deployment ID

model_id

Character. Model ID

species_id

Character. Species ID

spatial_ids

Reactive Character vector. Spatial Ids to use when populating spatial evaluation selectizes.

opts

List. Options list of reactives, originates from sdm_tool().

abandoned

ReactiveVal indicating whether the evaluation has been abandoned.

unsaved

ReactiveVal indicating whether any questions are unsaved.

Value

Server function for Shiny module


Utility Module 'Evaluations' UI

Description

Called by page-level modules to create the Evaluations UI in the right-hand side bar.

Usage

mod_utils_evaluations_ui(
  id = "evaluations",
  review_width = NULL,
  level = "species"
)

Arguments

id

Shiny module ID

review_width

Character. Starting width of the sidebar.

level

Character. Level of evaluations, "model" or "species".

Value

Shiny UI


Utility Module 'Map Selections' Server

Description

Highlights spatial ids selected on the map, either through user selection or through the 'show' button from evaluations.

Usage

mod_utils_map_selections_server(
  id,
  data,
  spatial_selection,
  interactions,
  parent_session = getDefaultReactiveDomain()
)

Arguments

id

Character. Shiny module ID

data

Spatial Data frame. Data from which selections will be made.

spatial_selection

List of show_clicked reactiveVal which indicates which show button was last clicked and show_spatial_ids which contains a list of spatial ids by category to highlight.

interactions

Interactions

parent_session

Parent session

Value

Shiny server


Utility Module 'Map Selections' UI

Description

Highlights spatial ids selected, either through user selection or through the 'show' button from evaluations. Called by component-level modules.

Usage

mod_utils_map_selections_ui(id)

Arguments

id

Character. Shiny module ID.

Value

Shiny UI


Utility Module 'Map Synchronization' Server

Description

Synchronizes the map view port among tabs

Usage

mod_utils_map_sync_server(
  id,
  parent_id,
  this_view,
  map_views,
  parent_session = getDefaultReactiveDomain()
)

Arguments

id

Character. Shiny module ID

parent_id

Character. Parent tab ID (used to identify which tab is active)

this_view

Reactive. Reactive that returns the current map view (list with zoom and lat/lon)

map_views

List. List of reactiveVals active_tab, set_by and view (list with zoom and lat/lon).

parent_session

Shiny session. Parent session (used for leafletProxy)

Value

Shiny server


Prepare Model Fit Data

Description

Prepare Model Fit Data

Usage

model_fit_prep(model_id, species_id)

Arguments

model_id

Character. Model ID

species_id

Character. Species ID

Value

Data frame

Examples

model_fit_prep(model_ = "bam_v5_can71", species_id = "BBWO")

Create a Table for Model Fit Data

Description

Create a Table for Model Fit Data

Usage

model_fit_table(model_fit)

Arguments

model_fit

Data frame with model fit information

Value

Reactable table

Examples

model_fit_prep(model_id = "bam_v5_can71", species_id = "BBWO") |>
  model_fit_table()

Prepare Model Summary Data

Description

Prepare Model Summary Data

Usage

model_summary_prep(model_id, species_id)

Arguments

model_id

Character. Model ID

species_id

Character. Species ID

Value

Data frame

Examples

model_summary_prep(model_id = "bam_v5_can71", species_id = "BBWO")

Create a Table for Model Summary Data

Description

Create a Table for Model Summary Data

Usage

model_summary_table(model_summary)

Arguments

model_summary

Data frame. Model summary information

Value

A reactable table object

Examples

model_summary_prep(model_id = "bam_v5_can71", species_id = "BBWO") |>
  model_summary_table()

Create named lists of ids for input selections

Description

Lists are c(named = id) to create a input selection with 'pretty' selections returning original ids.

Usage

named_ids(df_db, id = "id", name = "name", match = NULL)

Arguments

df_db

Data frame or database where ID values can be found.

id

Character. Pattern matching 'id' in the column name.

name

Character. Pattern matching 'name' in the column name.

match

Character. ID/Name preface. Optional instead of id/name, useful if there are more than one pair of id/name in the data frame.

Value

Named character vector.

Examples

df <- data.frame(
  species_id = c("X11", "Y22"),
  species_name = c("Pretty name", "Lovely name")
)

named_ids(df)
named_ids(df, match = "species")

Create a Leaflet Map of Observation Data

Description

Can use points or rasters to map the data.

Usage

obs_map(
  obs,
  subunits = NULL,
  ns = identity,
  output_type = c("points", "raster"),
  ...
)

Arguments

obs

sf or Terra spatial data. Observations as points (obs_prep()) or raster data (obs_prep_raster()).

subunits

Subunits

ns

Namespace

output_type

Character. Points or raster.

...

Other parameters.

Value

A leaflet map object

Examples

o <- obs_prep(model_id = "bam_v5_can71", species_id = "BBWO")
s <- deployment_subunits_prep("deployment1")
r0 <- prep_materials(
  "spatial_prediction",
  model_id = "bam_v5_can71",
  species_id = "BBWO"
)
r <- obs_prep_raster(o, r0)

obs_map(o, s) # points
obs_map(r, s, output_type = "raster") # raster

Create a Leaflet Map of Observation Point Data

Description

Create a Leaflet Map of Observation Point Data

Usage

obs_map_points(obs, subunits = NULL, ns = identity, ...)

Arguments

obs

sf data frame. Observations

subunits

Subunits

ns

Namespace

...

Other parameters.

Value

A leaflet map object

Examples

p <- test_points()
obs_map_points(p)

Create a Leaflet Map of Observation Raster Data

Description

Create a Leaflet Map of Observation Raster Data

Usage

obs_map_raster(obs, subunits = NULL, ns = identity, ...)

Arguments

obs

sf data frame. Observations

subunits

Subunits

ns

Namespace

...

Other parameters.

Value

A leaflet map object

Examples

o <- obs_prep(model_id = "bam_v5_can71", species_id = "BBWO")
r <- prep_materials(
  "spatial_prediction",
  model_id = "bam_v5_can71",
  species_id = "BBWO"
)
p <- obs_prep_raster(o, r)

obs_map_raster(p)

Prepare Observation Data

Description

Loads and generally prepares the observation data. Wrapper around obs_prep_points() and obs_prep_raster().

Usage

obs_prep(model_id, species_id, output_type = c("points", "raster"), ...)

Arguments

model_id

Character. Model ID

species_id

Character. Species ID

output_type

Character. Points or raster.

...

Other parameters. Most importantly, rast argument if output_type == "raster".

Value

Spatial data frame, sf if points, terra SpatRaster if raster.

Examples

r0 <- prep_materials(
  "spatial_prediction",
  model_id = "bam_v5_can71",
  species_id = "BBWO"
)

# Points Prep
obs_prep(model_id = "bam_v5_can71", species_id = "BBWO")

# Raster Prep
obs_prep(model_id = "bam_v5_can71", species_id = "BBWO", "raster", rast = r0)

Prepare points from Observation point data

Description

Prepare points from Observation point data

Usage

obs_prep_points(obs, ...)

Arguments

obs

Observation materials

...

Unused.

Value

Sf spatial data frame

Examples

o <- prep_materials(
  "observations",
  model_id = "bam_v5_can71",
  species_id = "BBWO"
)
p <- obs_prep_points(o)

Prepare raster from Observation point data

Description

Prepare raster from Observation point data

Usage

obs_prep_raster(obs, rast, scale = 10, ...)

Arguments

obs

Observation materials

rast

Spatial predictions raster to get the extent etc.

scale

Raster scale.

...

Unused.

Value

SpatRaster

Examples

o <- prep_materials(
  "observations",
  model_id = "bam_v5_can71",
  species_id = "BBWO"
)
r <- prep_materials(
  "spatial_prediction",
  model_id = "bam_v5_can71",
  species_id = "BBWO"
)
p <- obs_prep_raster(o, r)

Create vector of values to use downstream

Description

Creates a vector of Spatial values to use downstream when referencing parent values in followup questions.

Usage

parent_vals(v)

Arguments

v

Character vector of Questions values.

Value

Character vector of Question values formatted for Shiny Inputs, including only spatial values.

Examples

parent_vals(c("Slightly agree", "Very biased", "Moderately biased"))

Prepare Predictor Metadata Data

Description

Prepare Predictor Metadata Data

Usage

predictor_metadata_prep(model_id)

Arguments

model_id

Character. Model ID

Value

Data frame

Examples

predictor_metadata_prep("bam_v5_can71")

Create a Table for Predictor Metadata

Description

Create a Table for Predictor Metadata

Usage

predictor_metadata_table(predictor_metadata)

Arguments

predictor_metadata

Data frame. Predictor metadata

Value

A reactable table object

Examples

predictor_metadata_prep("bam_v5_can71") |>
  predictor_metadata_table()

Add a Prediction Raster Layer to an existing map

Description

Add a Prediction Raster Layer to an existing map

Usage

predictor_raster_layer(map, raster = NULL, layers = NULL)

Arguments

map

Leaflet map.

raster

SpatRaster. Raster from which to get layers to plot.

layers

Character vector. Layers in SpatRaster to plot.

Value

Leaflet map

Examples

r <- predictor_raster_prep("bam_v5_can71")
base_map() |>
  predictor_raster_layer(r, "mean")

Create a Leaflet Map of Predictor Raster Data

Description

Create a Leaflet Map of Predictor Raster Data

Usage

predictor_raster_map(predictor_raster, layers = NULL, subunits = NULL)

Arguments

predictor_raster

terra SpatRaster. Predictor information.

layers

Character vector. Layers in SpatRaster to plot.

subunits

Spatial Data frame. Deployment subunits.

Value

A leaflet map object

Examples

predictor_raster_prep("bam_v5_can71") |>
  predictor_raster_map(
    layers = "AHM_1km", # Must be a layer in prepared raster
    subunits = deployment_subunits_prep("deployment1")
  )

Prepare Predictor Raster Data

Description

Prepare Predictor Raster Data

Usage

predictor_raster_prep(model_id)

Arguments

model_id

Character. Model ID

Value

terra Raster

Examples

predictor_raster_prep("bam_v5_can71")

Prepare Deployments

Description

Prepare Deployments

Usage

prep_deployments(deployment_id, deployment_type)

Arguments

deployment_id

Character. Deployment ID

deployment_type

Character. Type of data to load ("deployment_questions" or "deployment_subunits")

Value

Data frame of deployments

Examples

prep_deployments("deployment1", "deployment_questions")
prep_deployments("deployment1", "deployment_subunits")
prep_deployments("deployment2", "deployment_questions")

Fetch and format submitted evaluations

Description

Fetch and format submitted evaluations

Usage

prep_evaluations(user_id, deployment_id = NULL)

Arguments

user_id

Character. User ID.

deployment_id

Character. Deployment ID

Value

Data frame of evaluation details

Examples

prep_evaluations("testuser") # Returns 0 rows if no evaluations

Generic file prep

Description

Generic file prep

Usage

prep_files(path, name, ...)

Arguments

path

Character. File path to fetch.

name

Character. Name of data for messaging

...

Named model, species, etc. values. See data from sdmEvalToolCore::make_target_path().

Value

File contents depending on file type (see sdmEvalToolCore::read_file()


Prepare Material Settings

Description

Prepare Material Settings

Usage

prep_material_settings(component_id, model_id, species_id = NULL)

Arguments

component_id

Character. Component ID

model_id

Character. Model ID

species_id

Character. Species ID

Value

A list with material settings

Examples

prep_material_settings("observations", species_id = "BBWO", model_id = "bam_v5_can71")
prep_material_settings("predictor_metadata", model_id = "bam_v5_can71")
prep_material_settings("spatial_prediction", species_id = "BBWO", model_id = "bam_v5_can71")
prep_material_settings("model_summary", species_id = "BBWO", model_id = "bam_v5_can71")
prep_material_settings("model_fit", species_id = "BBWO", model_id = "bam_v5_can71")
prep_material_settings("model_metadata", model_id = "bam_v5_can71")

Load material files

Description

Load material files

Usage

prep_materials(component_id, model_id, species_id = NULL)

Arguments

component_id

Character. Component ID

model_id

Character. Model ID

species_id

Character. Species ID

Value

Loaded file as an R object, material settings returned as an attribute.

Examples

prep_materials("observations", species_id = "BBWO", model_id = "bam_v5_can71")
prep_materials("model_metadata", model_id = "bam_v5_can71")
prep_materials("predictor_metadata", model_id = "bam_v5_can71")
#prep_materials("predictor_raster", model_id = "bam_v5_can71")
prep_materials("spatial_prediction", species_id = "BBWO", model_id = "bam_v5_can71")
prep_materials("model_summary", species_id = "BBWO", model_id = "bam_v5_can71")
prep_materials("model_fit", species_id = "BBWO", model_id = "bam_v5_can71")


# Expect Errors
# prep_materials("observations", model_id = "", species_id = "")
# prep_materials("observations", model_id = "bam_v5_can71", species_id = "")

Prepare Evaluation Questions

Description

Reads, combines and prepares questions for use in UIs. model_id and species_id required to create material_id.

Usage

prep_questions(
  component_id,
  deployment_id,
  model_id,
  species_id,
  user_id = NULL
)

Arguments

component_id

Character. Component ID

deployment_id

Character. Deployment ID

model_id

Character. Model ID

species_id

Character. Species ID

user_id

Character. User ID.

Value

Data frame of questions

Examples

# Return all questions
prep_questions("ALL", "deployment1", "bam_v5_can71", "BBWO")

# Return component specific questions
prep_questions("observations", "deployment1", "bam_v5_can71", "BBWO")
prep_questions("model_fit", "deployment1", "bam_v5_can71")
prep_questions("model_summary", "deployment1", "bam_v5_can71")

prep_questions(c("model_summary", "model_fit"), "deployment1", "bam_v5_can71")

prep_questions("predictor_raster", "deployment1", "bam_v5_can71")

# Return default questions
prep_questions("observations", "deployment_test", "bam_v5_can71", "BBWO")

# Follow up questions
prep_questions("model_fit", "deployment2", "bam_v5_can71", "BBWO")
prep_questions("observations", "deployment1", "bam_v5_can71", "BBWO")

# Add evaluations
#prep_questions("observations", "deployment1", "bam_v5_can71", "BBWO", "draper")
prep_questions("observations", "deployment1", "bam_v5_can71", "BBWO", "testuser")

# For the abandon review
prep_questions("app", "deployment1",  "bam_v5_can71", "BBWO", "testuser")

Create JSON evaluation body

Description

Takes component, questions data frame, and input list from Shiny app and converts responses (evaluations) to JSON body for saving to the data base.

Usage

response_to_json(component_id, questions, input_list)

Arguments

component_id

Character. Component ID.

questions

Data frame. From prep_questions().

input_list

List of evaluation inputs.

Examples

q1 <- test_questions("model_fit", "deployment2", "bam_v5_can71", "BBWO")
q2 <- test_questions("model_summary", "deployment2", "bam_v5_can71", "BBWO")
i1 <- test_input_evals(q1)
i2 <- test_input_evals(q2)
response_to_json("model_fit", rbind(q1, q2), append(i1, i2))

Save evaluations

Description

Save evaluations

Usage

save_evaluations(questions, input_list, user_id)

Arguments

questions

Data frame. Data frame of questions; output of prep_questions().

input_list

List. List of Shiny inputs; output of reactiveValuesToList(input)

user_id

Character. User ID.

Examples

q <- prep_questions(
  "observations",
  "deployment_test",
  "bam_v5_can71",
  "BBWO",
  "testuser"
)
a <- test_input_evals(q) # Create example evaluations
save_evaluations(q, a, user_id = "testuser")

# Compare
# Fetch saved from database
q <- prep_questions(
  "observations",
  "deployment_test",
  "bam_v5_can71",
  "BBWO",
  "testuser"
)
q <- evals_list(q) # Convert to list to compare
waldo::compare(a, q)

Create spinner when loading UI elements

Description

Create spinner when loading UI elements

Usage

sdm_spinner(ui_element)

Arguments

ui_element

Character. UI element name.

Value

UI element with spinner.


Theme for bslib

Description

Theme for bslib

Usage

sdm_theme()

Value

bslib theme

Examples

sdm_theme()

Launch the SDM Evaluation Tool Shiny Application

Description

Launch the SDM Evaluation Tool Shiny Application

Usage

sdm_tool(
  lang = "english",
  options = list(host = "0.0.0.0", port = 7405),
  tabs = c("overview", "predictions", "observations", "model", "predictors", "summary"),
  user = NULL,
  user_db = NULL,
  ...
)

Arguments

lang

Character. Language of app; either english or french.

options

List. Shiny app options (passed to options in shiny::shinyApp().

tabs

Character. List the tabs/pages that the UI should have.

user

Character. User id. Placeholder for now, used for testing.

user_db

A data frame with credentials data or path to SQLite database created with shinymanager::create_db().

...

Other arguments passed to shiny::shinyApp().

Value

A Shiny app object. Launched in browser/viewer if interactive.

Examples

sdm_tool()

Generate tool tip

Description

No tooltip if text NULL.

Usage

sdm_tooltip(
  tooltip_text,
  trigger = bsicons::bs_icon("info-circle", title = "Details")
)

Arguments

tooltip_text

Character. Text to make into the tooltip contents.

trigger

Code. Generally HTML tag lists to attach tooltip to. Defaults to (i) icon.

Value

bslib tooltip

Examples

sdm_tooltip("testing")
sdm_tooltip(
  "testing",
  shiny::tagList("Hi", bsicons::bs_icon("info-circle", title = "Details"))
)

Set sdmEvalTool options

Description

May not be necessary in the long run...

Usage

set_options(...)

Arguments

...

Named list of options to set

Value

list of options currently set


Get a list of selected spatial areas

Description

Returns a list of selected spatial areas by question value. Used to show selections on the map when "Show identified area" button associated with spatial questions is clicked.

Usage

show_spatial(show_clicked, questions, input)

Arguments

show_clicked

Button input for "Show identified area" for a specific spatial question. Only contains buttons just clicked.

questions

Data frame of original questions.

input

Input.

Value

Named list of Question values and spatial subunits for each.

Examples

# Example from test_page_summary()
c <- "deployment_subunits"
d <- "deployment1"
m <- "bam_v5_can71"
s <- "BBWO"
o <- 2
v <- "Confident"
sp <- paste(d, m, s, c, o, 0, sep = "_")

input <- list(c(4,5,9))
names(input) <- paste0(sp, "-", v)
clicked <- paste0(sp, "-show")
questions <- test_questions(c, d, m, s)
show_spatial(clicked, questions, input)

# Example from test_page_preditions()
c <- "spatial_prediction"
d <- "deployment1"
m <- "bam_v5_can71"
s <- "BBWO"
o <- 1
v <- c("Severe_over", "Moderate_over", "Accurate", "Moderate_under", "Severe_under", "Unknown")
sp <- paste(d, m, s, c, o, 0, sep = "_")

input <- list(c(4,5,9), NULL, NULL, c(3,5,10), NULL, NULL)
names(input) <- paste0(sp, "-", v)
clicked <- paste0(sp, "-show")
questions <- test_questions(c, d, m, s)
show_spatial(clicked, questions, input)

Skip testthat tests if no data is detected

Description

Skip testthat tests if no data is detected

Usage

skip_if_no_data()

Value

Logical


Create a Leaflet Map of Spatial Prediction Data

Description

Create a Leaflet Map of Spatial Prediction Data

Usage

spatial_prediction_map(spatial_prediction, subunits = NULL, ns = identity)

Arguments

spatial_prediction

terra Raster. Spatial predictions

subunits

Spatial Data frame. Deployment subunits.

ns

Namespace.

Value

A leaflet map object

Examples

p <- spatial_prediction_prep(model_id = "bam_v5_can71", species_id = "BBWO")
s <- deployment_subunits_prep("deployment1")
spatial_prediction_map(p)
spatial_prediction_map(p, s)

Prepare Spatial Prediction Data

Description

Prepare Spatial Prediction Data

Usage

spatial_prediction_prep(model_id, species_id)

Arguments

model_id

Character. Model ID

species_id

Character. Model ID

Value

terra Raster

Examples

spatial_prediction_prep(model_id = "bam_v5_can71", species_id = "BBWO")

Prepare Template Data

Description

Prepare Template Data

Usage

template_prep(model_id, species_id)

Arguments

model_id

Character. Model ID

species_id

Character. Species ID

Value

Data frame

Examples

template_prep(model_ = "bam_v5_can71", species_id = "BBWO")

Create a Leaflet Map of Template Spatial Data

Description

Create a Leaflet Map of Template Spatial Data

Usage

template_spatial_map(template_spatial, subunits = NULL, ns = identity)

Arguments

template_spatial

terra Raster. Template spatial data

subunits

Spatial Data frame. Deployment subunits.

ns

Namespace.

Value

A leaflet map object

Examples

p <- template_spatial_prep(model_id = "bam_v5_can71", species_id = "BBWO")
s <- deployment_subunits_prep("deployment1")
template_spatial_map(p)
template_spatial_map(p, s)

Prepare Template Spatial Data

Description

Prepare Template Spatial Data

Usage

template_spatial_prep(model_id, species_id)

Arguments

model_id

Character. Model ID

species_id

Character. Model ID

Value

terra Raster

Examples

template_spatial_prep(model_id = "bam_v5_can71", species_id = "BBWO")

Create a Table for Template Data

Description

Create a Table for Template Data

Usage

template_table(template)

Arguments

template

Data frame with template information

Value

Reactable table

Examples

template_prep(model_id = "bam_v5_can71", species_id = "BBWO") |>
  template_table()

Create Test App for Component Modules

Description

Not all arguments are used by all modules.

Usage

test_comp(
  module,
  use = c("parent_id", "deployment_id", "model_id", "species_id", "spatial_ids",
    "spatial_selection", "map_views"),
  deployment_id = "deployment1",
  model_id = "bam_v5_can71",
  species_id = "BBWO",
  spatial_ids = NULL,
  spatial_selection = list(show_clicked = NULL, show_spatial_ids = NULL),
  map_views = list(active_tab = NULL, set_by = NULL, view = NULL)
)

Arguments

module

Character. Module Name.

use

Character vector. Objects to include

deployment_id

Character. Example Deployment ID.

model_id

Character. Example Model ID.

species_id

Character. Example Species ID.

spatial_ids

Character. Optional starting spatial ids.

spatial_selection

List. Optional starting spatial selection (show_clicked and show_spatial_ids).

map_views

List. Optional set map views for map synchronization.

Value

Shiny App


Test the Deployment Subunits Component

Description

Test the Deployment Subunits Component

Usage

test_comp_deployment_subunits(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_deployment_subunits()

Test the Model Fit Component

Description

Test the Model Fit Component

Usage

test_comp_model_fit(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_model_fit()

Test the Model Summary Component

Description

Test the Model Summary Component

Usage

test_comp_model_summary(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_model_summary()

Test the Observations Chart Component

Description

Test the Observations Chart Component

Usage

test_comp_obs_chart(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_obs_chart()

Test the Observations Component

Description

Test the Observations Component

Usage

test_comp_observations(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_observations()

Test the Predictor Metadata Component

Description

Test the Predictor Metadata Component

Usage

test_comp_predictor_metadata(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_predictor_metadata()

Test the Predictor Raster Component

Description

Test the Predictor Raster Component

Usage

test_comp_predictor_raster(...)

Arguments

...

Other arguments.

Value

A Shiny app object

Examples

test_comp_predictor_raster()

Test the Spatial Prediction Component

Description

Test the Spatial Prediction Component

Usage

test_comp_spatial_prediction(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_spatial_prediction()

Test the Template Component

Description

Test the Template Component

Usage

test_comp_template(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_template()

Test the Template Spatial Component

Description

Test the Template Spatial Component

Usage

test_comp_template_spatial(...)

Arguments

...

Arguments passed to other functions.

Value

A Shiny app object

Examples

test_comp_template_spatial()

Create dummy json evaluation body

Description

This can be used for testing loading/extracting/counting/etc. questions. These are created by running the App, saving data, and then extracting the JSON bodies. They can be updated the same way. Note that there are different bodies to test different kinds of behaviour.

Usage

test_evaluation_body(component_id = "observations")

Arguments

component_id

Character. Id of the test evaluation body to use. Currently "observations", "model_fit_a", or "model_fit_b"

Value

Character. JSON string for hypothetical evaluation

Examples

test_evaluation_body()

## Not run: 
  # After created through app with 'testuser' and `deployment2` retrieved with:
  db_read_evaluations(db_connect_check(), "deployment2", "testuser") |>
    dplyr::filter(component_id == "model_fit") |>
    dplyr::slice(1) |>
    dplyr::pull(evaluation_body)

## End(Not run)

Create dummy input values for evaluations

Description

Create dummy input values for evaluations

Usage

test_input_evals(questions)

Arguments

questions

Data frame. Output of .prep_questions()

Value

List of dummy input values. Mimics and input object from the Shiny app.

Examples

q <- test_questions()
test_input_evals(q)

Create Test App for Page Modules

Description

Not all arguments are used by all modules.

Usage

test_page(
  module,
  deployment_id = "deployment1",
  model_id = "bam_v5_can71",
  species_id = "BBWO",
  user_id = "testuser",
  user_role = "evaluator",
  user_admin = FALSE,
  map_views = list(active_tab = NULL, set_by = NULL, view = NULL)
)

Arguments

module

Character. Module Name.

deployment_id

Character. Example Deployment ID.

model_id

Character. Example Model ID.

species_id

Character. Example Species ID.

user_id

Character. Example User ID.

user_role

Character. Example User Role.

user_admin

Logical. Example User Admin status.

map_views

List. Optional set map views for map synchronization.

Value

Shiny App


Create dummy sf point data

Description

Create dummy sf point data

Usage

test_points()

Value

sf data frame

Examples

test_points()

Create dummy questions for testing

Description

Create dummy questions for testing

Usage

test_questions(
  component = "observations",
  deployment_id = "deployment_test",
  model_id = "bam_v5_can71",
  species_id = "BBWO",
  types = c("spatial", "ordinal", "simple_text"),
  user_id = "testuser"
)

Arguments

component

Component.

deployment_id

Deployment ID.

model_id

Model ID.

species_id

Species ID.

types

Question types.

user_id

User id.

Examples

test_questions()

Create dummy terra SpatRaster data

Description

Create dummy terra SpatRaster data

Usage

test_raster()

Value

SpatRaster

Examples

test_raster()

Create tooltip from material settings

Description

Create tooltip from material settings

Usage

tt_material_settings(material)

Arguments

material

R Object depending on the type of material loaded. May have attributes such as 'material_settings'.

Value

bslib tooltip output from sdm_tooltip().


Create dynamic question inputs

Description

Create dynamic question inputs in the server using the prepared questions data frame.

Usage

ui_questions(questions, spatial_ids = NULL, width = NULL)

Arguments

questions

Data frame prepared by prep_questions() for a specific user_id.

spatial_ids

Character vector. [NOT CURRENTLY USED, see ui_questions_update()]. Only applies if using 'client-side selectize'. All possible Spatial ID options for spatial inputs choices. Generally passed in as ReactiveVal (see mod_page_template_spatial_server().

width

Numeric. Optional width of Shiny UI input.

Value

Shiny tagList of UI elements

Examples

q <- prep_questions(
  "observations",
  "deployment1",
  "bam_v5_can71",
  "BBWO",
  user_id = "testuser"
)
ui_questions(q)

# More than one component
q <- prep_questions(
  c("model_fit", "model_summary"),
  "deployment2",
  "bam_v5_can71",
  "BBWO",
  user_id = "testuser"
)
u <- ui_questions(q)

Update existing Spatial Shiny inputs

Description

Because there many be many possible selections for Spatial inputs, we use Serve-side processing to speed things up. This means that we initialize the Spatial input, and then we have to update it with the spatial input options (i.e. the list of spatial ids in the drop down menu). This function performs that update when the ids are ready (see the use of ui_questions_update() in mod_utils_evaluations_server().

Usage

ui_questions_update(questions, spatial_ids = NULL)

Arguments

questions

Data frame prepared by prep_questions() for a specific user_id.

spatial_ids

Character vector. [NOT CURRENTLY USED, see ui_questions_update()]. Only applies if using 'client-side selectize'. All possible Spatial ID options for spatial inputs choices. Generally passed in as ReactiveVal (see mod_page_template_spatial_server().

Value

Nothing. Performs Javascript update (see shiny::updateSelectizeInput()).


Validate input ids

Description

Validate input ids

Usage

validate_ids(...)

Arguments

...

Named arguments containing id values to validate (e.g., deployment_id, model_id, species_id)

Value

NULL (invisibly), or throws validation error if any id is missing


Helper function to format Question values as Shiny Input names

Description

Helper function to format Question values as Shiny Input names

Usage

value_to_input(v)

Arguments

v

Character vector of Question values.

Value

Character string of values formatted for Shiny Inputs

Examples

value_to_input("Strongly Agree")