R Under development (unstable) (2025-07-22 r88445 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > require(simsalapar) Loading required package: simsalapar > > vl <- varlist(n.sim = list(type="N", expr = quote(N[sim]), value = 7), + b = list(type="grid", value = 1:3), + a = list(type="grid", value = 1:2), + ii = list(type="inner", value = 1:5)) > (gr <- data.matrix(mkGrid(vl))) b a [1,] 1 1 [2,] 2 1 [3,] 3 1 [4,] 1 2 [5,] 2 2 [6,] 3 2 > > do.one <- function(a,b, ii) { + ## ii with names that are propagated (!) : + names(ii) <- paste("I", ii, sep=".") + t <- 10*(10*a + b) + round(runif(1), 1)/4 + ii + t + } > > set.seed(17) > rL <- doLapply(vl, doOne=do.one, repFirst=TRUE) > rL2 <- doLapply(vl, doOne=do.one, repFirst=FALSE) > > va <- getArray(rL , "value") > str(va) num [1:5, 1:3, 1:2, 1:7] 111 112 113 114 115 ... - attr(*, "dimnames")=List of 4 ..$ ii : chr [1:5] "I.1" "I.2" "I.3" "I.4" ... ..$ b : chr [1:3] "1" "2" "3" ..$ a : chr [1:2] "1" "2" ..$ n.sim: NULL > va2 <- getArray(rL2, "value") > str(va2) num [1:5, 1:3, 1:2, 1:7] 111 112 113 114 115 ... - attr(*, "dimnames")=List of 4 ..$ ii : chr [1:5] "I.1" "I.2" "I.3" "I.4" ... ..$ b : chr [1:3] "1" "2" "3" ..$ a : chr [1:2] "1" "2" ..$ n.sim: NULL > > stopifnot( all.equal(va, va2, tol = .001) ) > > > ## approximate mean result > am <- outer(1:5, 10*outer(1:3, 10*(1:2), "+"), "+") > > ## Test 'repFirst=TRUE' : > > m1 <- apply(va, 1:3, mean) > stopifnot(unname(dim(m1)) == dim(am)) # dim() match {apart from names} > dim (am) <- dim (m1) > dimnames(am) <- dimnames(m1) > stopifnot(all.equal(m1, am, tol = .001), + apply(va, 1:3, sd) < 0.1) > > ## Test 'repFirst=FALSE' : > > m2 <- apply(va2, 1:3, mean) > stopifnot(unname(dim(m2)) == dim(am)) # dim() match {apart from names} > stopifnot(all.equal(m2, am, tol = .001), + apply(va2, 1:3, sd) < 0.1) > > > proc.time() user system elapsed 0.54 0.09 0.62