Skip to content

Commit e3dc227

Browse files
authored
Merge pull request #71 from emstruong/main
Fix SimCheck Behavior
2 parents 4929f17 + 5210894 commit e3dc227

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

R/SimCheck.R

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
#'
1818
#' @seealso \code{\link{runArraySimulation}}, \code{\link{SimCollect}}
1919
#'
20-
#' @return returns an invisible vector of missing indicies. If no missing
21-
#' then an empty vector is returned
20+
#' @return returns an invisible list of indices of empty, missing and
21+
#' empty-and-missing row conditions.. If no missing then an empty list is
22+
#' returned
2223
#'
2324
#' @references
2425
#'
@@ -57,17 +58,27 @@ SimCheck <- function(dir = NULL, files = NULL, min = 1L, max = NULL){
5758
max <- attr(tmp, 'extra_info')$number_of_conditions
5859
}
5960
minmax <- min:max
60-
notin <- !(paste0(filename, '-', minmax, '.rds') %in% files)
61+
mainlist <- paste0(filename, '-', minmax, '.rds')
62+
have <- mainlist %in% files
63+
notin <- !have
64+
names(have) <- mainlist
65+
ret <- list()
6166
if(any(notin)){
67+
ret$Missing_Row_Conditions <- minmax[notin]
6268
warning(sprintf('The following row conditions were missing:\n%s\n',
63-
paste0(minmax[notin], collapse=',')))
69+
paste0(ret$Missing_Row_Conditions, collapse=',')))
6470
}
65-
nonzero <- sapply(files, file.size) > 0
66-
if(any(!nonzero))
71+
empty_file <- (sapply(names(have)[have], file.size, USE.NAMES = FALSE) == 0)
72+
if(any(empty_file)) {
73+
ret$Empty_Row_Conditions <- minmax[empty_file]
6774
warning(sprintf('The following row conditions have nothing saved:\n%s\n',
68-
paste0(minmax[!nonzero], collapse=',')))
69-
ret <- if(any(notin) || any(!nonzero)){
70-
which(notin | !nonzero) - 1 + min
75+
paste0(ret$Empty_Row_Conditions, collapse=',')))
76+
}
77+
if(any(notin) || any(empty_file)){
78+
ret$Empty_Missing_Row_Conditions <- c(minmax[notin], minmax[empty_file]) |>
79+
unique() |>
80+
sort()
7181
} else integer()
82+
7283
invisible(ret)
7384
}

0 commit comments

Comments
 (0)