From 761aeda21fdec45ad2deafda4c140ca17534634a Mon Sep 17 00:00:00 2001 From: philchalmers Date: Tue, 10 Dec 2024 12:24:25 -0500 Subject: [PATCH] closes #52 --- R/SimCollect.R | 11 +++++++++-- man/SimCollect.Rd | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/R/SimCollect.R b/R/SimCollect.R index ab9bf8d..7ccc04b 100644 --- a/R/SimCollect.R +++ b/R/SimCollect.R @@ -23,7 +23,8 @@ #' \code{SimExtract(what='results')} information. This is mainly useful when RAM is an issue #' given simulations with many stored estimates. Default includes the results objects #' in their entirety, though to omit all internally stored simulation results pass the -#' character \code{'NONE'} +#' character \code{'NONE'}. To investigate the stored warnings and error messages in isolation +#' pass \code{'WARNINGS'} or \code{'ERRORS'}, respectively #' #' @param check.only logical; for larger simulations file sets, such as those generated by #' \code{\link{runArraySimulation}}, return the design conditions that do no satisfy the @@ -145,6 +146,9 @@ #' sim <- SimCollect('sim_files/') #' sim #' +#' # view list of error messages (if there were any raised) +#' SimCollect('sim_files/', select = 'ERRORS') +#' #' SimClean(dir='sim_files/') #' #' } @@ -189,12 +193,15 @@ SimCollect <- function(dir=NULL, files = NULL, filename = NULL, tmp <- try(readRDS(filenames[i]), TRUE) if(is(tmp, 'try-error')) stop(c('Could not read file ', filenames[i])) - readin[[i]] <- subset_results(tmp, select=select) + readin[[i]] <- if(!is.null(select) && select %in% c('ERRORS', 'WARNINGS')){ + SimExtract(tmp, what=tolower(select)) + } else subset_results(tmp, select=select) if(gc){ rm(tmp) gc() } } + if(!is.null(select) && select %in% c('ERRORS', 'WARNINGS')) return(readin) extra_info1 <- attr(readin[[1L]], 'extra_info') ncores <- sum(sapply(readin, function(x) attr(x, 'extra_info')$ncores)) extra_info1[c("seeds", "date_completed", "summarise_list", "stored_results", diff --git a/man/SimCollect.Rd b/man/SimCollect.Rd index b7e6131..a58f66c 100644 --- a/man/SimCollect.Rd +++ b/man/SimCollect.Rd @@ -34,7 +34,8 @@ then the results will only be returned in the R console.} \code{SimExtract(what='results')} information. This is mainly useful when RAM is an issue given simulations with many stored estimates. Default includes the results objects in their entirety, though to omit all internally stored simulation results pass the -character \code{'NONE'}} +character \code{'NONE'}. To investigate the stored warnings and error messages in isolation +pass \code{'WARNINGS'} or \code{'ERRORS'}, respectively} \item{check.only}{logical; for larger simulations file sets, such as those generated by \code{\link{runArraySimulation}}, return the design conditions that do no satisfy the @@ -151,6 +152,9 @@ SimCollect('sim_files/', check.only = TRUE, target.reps=1000) sim <- SimCollect('sim_files/') sim +# view list of error messages (if there were any raised) +SimCollect('sim_files/', select = 'ERRORS') + SimClean(dir='sim_files/') }