Skip to content

Commit fc096c9

Browse files
committed
same logic, but avoid changing vectors
1 parent b6c93e4 commit fc096c9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

R/runArraySimulation.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,11 @@ runArraySimulation <- function(design, ..., replications,
329329
stopifnot(nrow(design) > 1L)
330330
stopifnot("arrayID is not a single integer identifier"=
331331
length(arrayID) == 1L && is.numeric(arrayID) && !is.na(arrayID))
332+
if(length(replications) == 1)
333+
replications <- rep(replications, nrow(design))
332334
rowpick <- array2row(arrayID)
333335
filename_suffix <- paste0("-", rowpick)
334336
stopifnot(!missing(replications))
335-
if(length(replications) > 1L)
336-
replications <- replications[rowpick]
337-
if(length(replications) == 1)
338-
replications <- rep(replications, length(rowpick))
339337
stopifnot(rowpick %in% 1L:nrow(design))
340338
if(!is.null(filename))
341339
filename <- paste0(filename, filename_suffix)
@@ -354,7 +352,7 @@ runArraySimulation <- function(design, ..., replications,
354352
seed <- genSeeds(design, iseed=iseed, arrayID=row)
355353
dsub <- design[row, , drop=FALSE]
356354
attr(dsub, 'Design.ID') <- attr(design, 'Design.ID')[row]
357-
ret <- runSimulation(design=dsub, replications=replications[i], seed=seed,
355+
ret <- runSimulation(design=dsub, replications=replications[row], seed=seed,
358356
verbose=verbose, save_details=save_details,
359357
parallel=parallel, ncores=ncores, cl=cl,
360358
control=control, save=FALSE, resume=FALSE, ...)

0 commit comments

Comments
 (0)