Creates a nodes-by-edges matrix that will be used by aem() of the package adespatial. This function creates the same output as aem.build.binary() of the package adespatial but works in a different way: it's only based on node labels (not on coordinates). Also, this function adds labels to nodes and edges.

nodes_by_edges_matrix(edges)

Arguments

edges

a data.frame with the following two columns: from (the first node of the edge) and to (the second node of the edge).

Value

A list of two elements:

  • se.mat: the nodes-by-edges matrix of dimensions n x k, where n is the number of nodes and k the number of edges (including the edge between the fictitious origin and the first site);

  • edges: a data.frame of edge list.

Examples

library("chessboard")

# Two-dimensional sampling ----
sites_infos <- expand.grid("transect" = 1:3, "quadrat" = 1:5)
sites_infos
#>    transect quadrat
#> 1         1       1
#> 2         2       1
#> 3         3       1
#> 4         1       2
#> 5         2       2
#> 6         3       2
#> 7         1       3
#> 8         2       3
#> 9         3       3
#> 10        1       4
#> 11        2       4
#> 12        3       4
#> 13        1       5
#> 14        2       5
#> 15        3       5

nodes <- create_node_labels(data     = sites_infos, 
                            transect = "transect", 
                            quadrat  = "quadrat")

edges <- create_edge_list(nodes, method = "pawn", directed = TRUE)

# Create nodes-by-edges matrix ----
nodes_by_edges_matrix(edges)
#> $se.mat
#>     E-01 E-02 E-03 E-04 E-05 E-06 E-07 E-08 E-09 E-10 E-11 E-12 E-13 E-14 E-15
#> 1-1    1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 1-2    1    0    0    1    0    0    0    0    0    0    0    0    0    0    0
#> 1-3    1    0    0    1    1    0    0    0    0    0    0    0    0    0    0
#> 1-4    1    0    0    1    1    1    0    0    0    0    0    0    0    0    0
#> 1-5    1    0    0    1    1    1    1    0    0    0    0    0    0    0    0
#> 2-1    0    1    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 2-2    0    1    0    0    0    0    0    1    0    0    0    0    0    0    0
#> 2-3    0    1    0    0    0    0    0    1    1    0    0    0    0    0    0
#> 2-4    0    1    0    0    0    0    0    1    1    1    0    0    0    0    0
#> 2-5    0    1    0    0    0    0    0    1    1    1    1    0    0    0    0
#> 3-1    0    0    1    0    0    0    0    0    0    0    0    0    0    0    0
#> 3-2    0    0    1    0    0    0    0    0    0    0    0    1    0    0    0
#> 3-3    0    0    1    0    0    0    0    0    0    0    0    1    1    0    0
#> 3-4    0    0    1    0    0    0    0    0    0    0    0    1    1    1    0
#> 3-5    0    0    1    0    0    0    0    0    0    0    0    1    1    1    1
#> 
#> $edges
#>      from  to
#> E-01    0 1-1
#> E-02    0 2-1
#> E-03    0 3-1
#> E-04  1-1 1-2
#> E-05  1-2 1-3
#> E-06  1-3 1-4
#> E-07  1-4 1-5
#> E-08  2-1 2-2
#> E-09  2-2 2-3
#> E-10  2-3 2-4
#> E-11  2-4 2-5
#> E-12  3-1 3-2
#> E-13  3-2 3-3
#> E-14  3-3 3-4
#> E-15  3-4 3-5
#>