View source: R/create_relation_matrix.R
| create_relation_matrix | R Documentation |
Creates a new adjacency matrix or converts existing data to an adjacency matrix format suitable for ISM analysis.
create_relation_matrix(input, from = 1, to = 2, nodes = NULL)
input |
Input data. Accepts:
|
from |
Column position or name for source nodes (when input is an edge list). Default is 1. |
to |
Column position or name for target nodes (when input is an edge list). Default is 2. |
nodes |
Optional character vector of predefined node names. Ensures matrix completeness when converting from edge lists. |
This function provides a unified interface for creating adjacency matrices in ISM analysis. It handles three common scenarios:
Creating an empty matrix of specified size for manual population
Converting edge list data (data.frame or matrix) to adjacency format
Validating existing adjacency matrices
A square adjacency matrix with node labels as dimnames. A value of 1 at position (i,j) indicates a directed relationship from element i to element j.
convert_to_matrix for the underlying conversion logic,
compute_reachability for computing reachability matrices.
# Create a 3x3 zero matrix
create_relation_matrix(3)
# Create with custom node labels
create_relation_matrix(3, nodes = c("A", "B", "C"))
# Convert edge list data.frame
edge_df <- data.frame(source = c("A", "B"), target = c("B", "C"))
create_relation_matrix(edge_df, from = "source", to = "target",
nodes = LETTERS[1:4])
# Validate existing matrix
existing_mat <- matrix(c(0, 1, 1, 0), nrow = 2)
create_relation_matrix(existing_mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.