Learn R Programming

stCEG (version 0.1.0)

generate_CEG_map: Generate a Leaflet Map for a Chain Event Graph (CEG)

Description

This function generates an interactive map using the Leaflet package to visualize the probability of each area in the Chain Event Graph (CEG). The map is color-coded based on area-specific probabilities, which are calculated from the path products and conditional probabilities.

Usage

generate_CEG_map(
  shapefile,
  ceg_object,
  conditionals = unique(ceg_object$x$edges$label1),
  colour_by = NULL,
  color_palette = "viridis"
)

Value

A Leaflet map object with color-coded polygons representing the areas, with a legend indicating the probability values for each area.

Arguments

shapefile

A Simple Features (sf) object representing the shapefile data for the geographical areas.

ceg_object

A list containing the Chain Event Graph (CEG) data, including nodes and edges.

conditionals

A character vector containing the conditions (labels) to condition on when calculating area probabilities. Default is the unique edge labels from the ceg_object.

colour_by

A string specifying the label by which to color the map. Default is NULL, which colors by the label with the maximum level.

color_palette

A string specifying the color palette to use for the map. Default is "viridis".

Examples

Run this code
data <- homicides
event_tree <- create_event_tree(data, columns = c(9,2,4,5), "both")
coloured_tree <- ahc_colouring(event_tree)

tree_priors <- specify_priors(coloured_tree, prior_type = "Uniform", ask_edit = FALSE)
staged_tree <- staged_tree_prior(coloured_tree, tree_priors)
ceg <- create_ceg(staged_tree, view_table = TRUE)
generate_CEG_map(bcu_shapefile, ceg)

Run the code above in your browser using DataLab