Skip to content

Commit

Permalink
make SimResults output consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Dec 2, 2024
1 parent d6d78f1 commit 10dea9e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SimDesign
Title: Structure for Organizing Monte Carlo Simulation Designs
Version: 2.17.4
Version: 2.17.5
Authors@R: c(person("Phil", "Chalmers", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID="0000-0001-5332-2810")),
person("Matthew", "Sigal", role = c("ctb")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Changes in SimDesign 2.18

- `SimResults()` now gives the same output behavior when `store_results` or
`save_results` are used (see issue #45)

- Use of `SimSolve(..., wait.time)` now automatically sets the `maxiter` to
3000 to avoid early terminations

Expand Down
17 changes: 13 additions & 4 deletions R/SimResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,20 @@ SimResults <- function(obj, which, prefix = "results-row", wd = getwd()){
file_nums <- gsub(paste0(prefix, '-'), '', file_nums)
file_nums <- as.numeric(gsub('.rds', '', file_nums))
files <- data.frame(file_nums, files, stringsAsFactors = FALSE)
ret <- vector('list', length(which))
stored_Results_list <- vector('list', length(which))
for(i in seq_len(length(which))){
pick <- which(files$file_num == which[i])
ret[[i]] <- readRDS(files$files[pick])
stored_Results_list[[i]] <- readRDS(files$files[pick])
}
if(length(which) == 1L) ret <- ret[[1]]
ret
design <- SimExtract(obj, 'design')
if(is(stored_Results_list[[1L]]$results, 'data.frame') ||
is(stored_Results_list[[1L]]$results, 'matrix')){
for(i in seq_len(length(stored_Results_list)))
stored_Results_list[[i]] <- cbind(design[i,],
stored_Results_list[[i]]$results, row.names=NULL)
stored_Results_list <- dplyr::bind_rows(stored_Results_list)
stored_Results_list$ID <- NULL
stored_Results_list <- dplyr::as_tibble(stored_Results_list)
}
stored_Results_list
}
14 changes: 6 additions & 8 deletions man/SimSolve.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10dea9e

Please sign in to comment.