scanList2matList: Convert scanList 3D array into list of 2D matrices

Description Usage Arguments Details Value Examples

View source: R/scanList_matList_conversion.R

Description

Convenience function to allow the use of functions designed to affect list of matrices instead of 3D array (specifically scanList objects) where the 3rd dimension is the scan index. Keeps track of the attributes list attrs

Usage

1
scanList2matList(scan.list)

Arguments

scan.list

a 3 dimensional array representing adjacency matrices (first 2 dimensions) throughout the different scans (3rd dimension)

Details

To back-transform a list of matrices into a scanList object, users can use matList2array(), wrapper to simplify2array() that handles attributes list attrs

Value

a list of matrices where each element is the 2D matrix for each scan index (3rd dimension of array.3D)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
set.seed(42)
n <- 5L
samp.effort <- 100L

# Adjacency matrix import
## random directed adjacency matrix
Adj <- sample(1:samp.effort,n * n) |>
  matrix(nrow = 5,dimnames = list(letters[1:n],letters[1:n]))
Adj[lower.tri(Adj,diag = TRUE)] <- 0L
Adj

sL <- simunet(Adj,samp.effort,"upper",10)
mL <- sL |> scanList2matList()
mL
mL |> matList2scanList()
identical(mL |> matList2scanList(),sL)

R-KenK/SimuNet documentation built on Oct. 22, 2021, 1:27 a.m.