list2mat: Convert List of matrices to a matrix.

Description Usage Arguments Details Value Examples

View source: R/list2mat.R

Description

list2mat converts a list of matrices to a matrix in which each orginal matrix locates in the diagonal and off-diagonal cells are set to be NA (by default).

Usage

1
list2mat(mats = mats, fill = NA)

Arguments

mats

the matrices stored in a list format. array is also possible to supply as input, if the first dimension of the array indicats the each network, and the second and third are the row and column of the matrix (this is the default format of package sna).

fill

the value of the off-diagonal cells. The defalut value is NA.

Details

This function convertes a original list of matrices to a new matrix in which each orginal matrix locates in the diagonal and of diagonal cells are set to be NA (the filler can be set by changing fill. This conversion is useful, for example, when running an QAP regression with the intention to find out the coefficients across networks.

Value

a matrix converted from the list of matrices.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## library(sna)
mat1 <- rgraph(3)
dimnames(mat1) <- list(paste(rep("A", 3), 1:3, sep = ""),
                      paste(rep("A", 3), 1:3, sep = ""))
mat2 <- rgraph(4)
dimnames(mat2) <- list(paste(rep("B", 4), 1:4, sep = ""),
                      paste(rep("B", 4), 1:4, sep = ""))
mat3 <- rgraph(2)
dimnames(mat3) <- list(paste(rep("C", 2), 1:2, sep = ""),
                      paste(rep("C", 2), 1:2, sep = ""))
mats <- list(mat1, mat2, mat3)

list2mat(mats, fill = NA)

huhn1234/vogeltools documentation built on Jan. 17, 2020, 5:21 p.m.