sLapply: Shortcut to a 'lapply' equivalent to apply a function to each...

Description Usage Arguments Value Examples

View source: R/scanList_tools.R

Description

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

Usage

1
sLapply(sL, FUN, ...)

Arguments

sL

a scanList object (see simunet())

FUN

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

...

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

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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 = Adj,samp.effort = samp.effort,mode = "upper",n.scans = 120L)
sL |> sLapply(function(scan) {scan[1,2] <- NA;scan})

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