plot_interactive_ism: Interactive ISM Visualization

View source: R/plot_interactive.R

plot_interactive_ismR Documentation

Interactive ISM Visualization

Description

Generates interactive Interpretive Structural Model diagrams with node dragging, zooming, and level-based filtering capabilities. Requires the visNetwork package (suggested dependency).

Usage

plot_interactive_ism(
  reach_matrix,
  node_labels = NULL,
  level_result = NULL,
  show_transitive = FALSE,
  direction = c("UD", "LR", "DU", "RL")
)

Arguments

reach_matrix

A reachability matrix (n x n) representing the ISM relationships.

node_labels

A character vector of length n specifying custom node labels. If NULL, uses matrix row names or numeric indices.

level_result

A list of class ism_levels representing level partitioning results from level_partitioning. If NULL, level partitioning is computed automatically.

show_transitive

Logical. If FALSE (default), transitive edges are removed for cleaner visualization. If TRUE, all edges are shown.

direction

Layout direction for visualization. Options:

  • "UD": Up-down (default)

  • "LR": Left-right

  • "DU": Down-up

  • "RL": Right-left

Details

This function requires the visNetwork package. If viridis is available, it will be used for level-based coloring; otherwise, a default color palette is used.

The interactive visualization provides several features:

  • Drag nodes: Click and drag to reposition nodes

  • Zoom: Use mouse wheel or navigation buttons

  • Highlight: Hover over nodes to highlight connections

  • Filter: Select nodes by ID or filter by level group

  • Keyboard navigation: Use arrow keys to navigate

By default, transitive edges are removed using extract_direct_edges to produce cleaner diagrams. Set show_transitive = TRUE to show all edges.

Value

An interactive visNetwork object that can be displayed in RStudio Viewer, Shiny apps, or web browsers.

See Also

plot_ism for static visualization, level_partitioning for computing hierarchical levels, compute_reachability for computing reachability matrices, extract_direct_edges for transitive reduction.

Examples


# Create sample data
adj_matrix <- matrix(c(0, 1, 0, 0,
                       0, 0, 1, 1,
                       0, 0, 0, 0,
                       0, 0, 0, 0), nrow = 4, byrow = TRUE)
rownames(adj_matrix) <- colnames(adj_matrix) <- LETTERS[1:4]
reach_matrix <- compute_reachability(adj_matrix)
levels <- level_partitioning(reach_matrix)

# Basic interactive plot (requires visNetwork)
if (requireNamespace("visNetwork", quietly = TRUE)) {
  plot_interactive_ism(reach_matrix)

  # With custom labels and levels
  plot_interactive_ism(reach_matrix,
                       node_labels = c("Factor A", "Factor B",
                                       "Factor C", "Factor D"),
                       level_result = levels)
}


ISMtools documentation built on March 13, 2026, 1:06 a.m.