Skip to content

Commit b6c93e4

Browse files
committed
improve replication budget subsetting
1 parent 1dd0dc8 commit b6c93e4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: SimDesign
22
Title: Structure for Organizing Monte Carlo Simulation Designs
3-
Version: 2.20.3
3+
Version: 2.20.4
44
Authors@R: c(person("Phil", "Chalmers", email = "[email protected]", role = c("aut", "cre"),
55
comment = c(ORCID="0000-0001-5332-2810")),
66
person("Matthew", "Sigal", role = c("ctb")),

R/runArraySimulation.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@
272272
#' # list saved files
273273
#' dir('sim/')
274274
#'
275+
#' # Also works if the replication input were a suitable vector (not run)
276+
#' if(FALSE){
277+
#' reps <- c(rep(10, 14), 100)
278+
#' cbind(Design5, reps)
279+
#' sapply(1:3, \(arrayID)
280+
#' runArraySimulation(design=Design5, replications=reps,
281+
#' generate=Generate, analyse=Analyse,
282+
#' summarise=Summarise, iseed=iseed, arrayID=arrayID,
283+
#' filename='condition', dirname='sim', array2row=array2row)) |> invisible()
284+
#' }
285+
#'
286+
#'
275287
#' # note that all row conditions are still stored separately, though note that
276288
#' # arrayID is now 2 instead
277289
#' condition14 <- readRDS('sim/condition-14.rds')
@@ -322,6 +334,8 @@ runArraySimulation <- function(design, ..., replications,
322334
stopifnot(!missing(replications))
323335
if(length(replications) > 1L)
324336
replications <- replications[rowpick]
337+
if(length(replications) == 1)
338+
replications <- rep(replications, length(rowpick))
325339
stopifnot(rowpick %in% 1L:nrow(design))
326340
if(!is.null(filename))
327341
filename <- paste0(filename, filename_suffix)
@@ -340,7 +354,7 @@ runArraySimulation <- function(design, ..., replications,
340354
seed <- genSeeds(design, iseed=iseed, arrayID=row)
341355
dsub <- design[row, , drop=FALSE]
342356
attr(dsub, 'Design.ID') <- attr(design, 'Design.ID')[row]
343-
ret <- runSimulation(design=dsub, replications=replications, seed=seed,
357+
ret <- runSimulation(design=dsub, replications=replications[i], seed=seed,
344358
verbose=verbose, save_details=save_details,
345359
parallel=parallel, ncores=ncores, cl=cl,
346360
control=control, save=FALSE, resume=FALSE, ...)

0 commit comments

Comments
 (0)