adj_to_dyadlist: Transform adjacency matrix to dyad-list

Description Usage Arguments Details Value Examples

View source: R/network_utils.R

Description

Transforms an adjacency matrix of dimension n times n to a choose(n, 2) times 4 dyad-list.

Usage

1

Arguments

x

numeric or integer matrix

Details

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.

Value

dyad-list

Examples

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)

baruuum/btoolbox documentation built on Aug. 17, 2020, 1:29 a.m.