View source: R/plot_interactive.R
| plot_interactive_ism | R Documentation |
Generates interactive Interpretive Structural Model diagrams with node dragging, zooming, and level-based filtering capabilities. Requires the visNetwork package (suggested dependency).
plot_interactive_ism(
reach_matrix,
node_labels = NULL,
level_result = NULL,
show_transitive = FALSE,
direction = c("UD", "LR", "DU", "RL")
)
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 |
level_result |
A list of class |
show_transitive |
Logical. If |
direction |
Layout direction for visualization. Options:
|
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.
An interactive visNetwork object that can be displayed in
RStudio Viewer, Shiny apps, or web browsers.
plot_ism for static visualization,
level_partitioning for computing hierarchical levels,
compute_reachability for computing reachability matrices,
extract_direct_edges for transitive reduction.
# 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.