connectivity_matrix {chessboard} | R Documentation |
Create a connectivity matrix from an edge list
Description
Converts an edge list to an connectivity matrix (also known as adjacency matrix).
Usage
connectivity_matrix(
edges,
lower = TRUE,
upper = TRUE,
diag = TRUE,
na_to_zero = TRUE
)
Arguments
edges |
a |
lower |
a |
upper |
a |
diag |
a |
na_to_zero |
a |
Value
A connectivity matrix of dimensions n x n
, where n
is the number
of nodes.
Examples
# Import Adour sites ----
path_to_file <- system.file("extdata", "adour_survey_sampling.csv",
package = "chessboard")
adour_sites <- read.csv(path_to_file)
# Select first location ----
adour_sites <- adour_sites[adour_sites$"location" == 1, ]
# Create node labels ----
adour_nodes <- create_node_labels(data = adour_sites,
location = "location",
transect = "transect",
quadrat = "quadrat")
# Find edges with 1 degree of neighborhood (pawn method) ----
adour_edges <- create_edge_list(adour_nodes, method = "pawn",
directed = TRUE)
# Get connectivity matrix ----
connectivity_matrix(adour_edges)
# Get connectivity matrix ----
connectivity_matrix(adour_edges, na_to_zero = FALSE)