Description Usage Arguments Details Value Examples
View source: R/network_utils.R
Transforms an adjacency matrix of dimension n
times n
to a choose(n, 2)
times 4
dyad-list.
1 |
x |
numeric or integer matrix |
The first column of the returned object contains identifiers for the rows of the adjacency matrix x
, i
, the second column contains identifiers for the columns, j
, the third column contains the tie from i
to j
, and the fourth column contains the tie from j
to i
.
The function will automatically determine whether x
is symmetric or not. If x
is symmetric, the returned dyadlist will consists of the first three columns only.
Notice that a matrix
class in R
can hold only a single data type. So, if the adjacency matrix contains character
-types, the resulting dyadlist will be of type character
as well. On the other hand, if the adjacency matrix contains logical
types, the function will return an integer
type dyad-list.
dyad-list
1 2 3 4 5 6 7 | # asymmetric case
A = matrix(runif(25), nrow = 5)
adj_to_dyadlist(A)
# symmetric case
A_sym = btoolbox::symmetrize(A, upper_to_lower = TRUE)
adj_to_dyadlist(A_sym)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.