Shortcut to a lapply equivalent to apply a function to each 2D matrix contained in a scanList Written analogously to vapply(). Values returned by .f should be a similarly dimensionned matrix as the first one contained in the 3D array

sLvapply(sL, .f, ..., USE.NAMES = TRUE)

Arguments

sL

a scanList object (see simunet())

.f

a function, to apply to each 2D matrix contained in sL

...

extra argument to be passed, notably named arguments used by .f (see lapply())

USE.NAMES

logical; if TRUE and if X is character, use X as names for the result unless it had names already (see vapply())

Value

a 3D array onto which the function has been applied to each scan

Examples

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
#> a b c d e #> a 0 100 37 27 58 #> b 0 0 20 36 42 #> c 0 0 0 5 93 #> d 0 0 0 0 30 #> e 0 0 0 0 0
sL <- simunet(Adj = Adj,samp.effort = samp.effort,mode = "upper",n.scans = 120L) sL |> sLvapply(function(scan) {scan[1,2] <- NA;scan})
#> #> scan: 1 #> a . NA 1 . 1 #> b . . . . . #> c . . . . 1 #> d . . . . . #> e . . . . . #> #> scan: 2 #> a . NA . . . #> b . . . . 1 #> c . . . . 1 #> d . . . . . #> e . . . . . #> #> ... ( 117 more scans) #> #> scan: 120 #> a . NA . . 1 #> b . . 1 1 . #> c . . . . 1 #> d . . . . 1 #> e . . . . . #> #> #> Hidden attributes: #> scanList.type - raw.scanList - Adj - samp.effort - n.scans - mode #> Adj.subfun - edge.Prob