@@ -168,8 +168,8 @@ generate_annual_frequency <- function(frequency, len){
168168# '
169169# ' @example
170170# '
171- get_saved_model_runs <- function (om_order = NULL , hcr_order = NULL ){
172- fs <- list.files(file.path(here :: here(), " data" , " active " ), full.names = TRUE )
171+ get_saved_model_runs_old <- function (om_order = NULL , hcr_order = NULL ){
172+ fs <- list.files(file.path(here :: here(), " data" , " mse_runs_good " ), full.names = TRUE )
173173 model_runs <- unlist(lapply(fs , function (x ){
174174 m <- readRDS(x )
175175 mse <- m $ mse_objects
@@ -202,6 +202,58 @@ get_saved_model_runs <- function(om_order=NULL, hcr_order=NULL){
202202
203203}
204204
205+ # ' Load Saved MSE Model Runs from Disk
206+ # '
207+ # ' Read all saved RDS files present in data/active and coerce into proper
208+ # ' model_runs list object. Also setup correctly specified extra_columns
209+ # ' object for use with bind_mse_outputs.
210+ # '
211+ # ' @param om_order vector of correct order of OMs (used to set OM factor level)
212+ # ' @param hcr_order vector of correct order of HCRs (used to set HCR factor level)
213+ # '
214+ # ' @export get_saved_model_runs
215+ # '
216+ # ' @example
217+ # '
218+ get_saved_model_runs <- function (om_order = NULL , hcr_order = NULL ){
219+ fs <- list.files(file.path(here :: here(), " data" , " active" ), full.names = TRUE )
220+ model_runs <- lapply(seq_along(fs ), function (i ){
221+ x <- fs [i ]
222+ m <- readRDS(x )
223+ mse <- m $ mse_objects
224+ mse [[length(mse )]]
225+ })
226+
227+ om_names <- sapply(fs , function (x ){
228+ m <- readRDS(x )
229+ m $ om $ name
230+ })
231+ names(om_names ) <- NULL
232+
233+ hcr_names <- sapply(fs , function (x ){
234+ m <- readRDS(x )
235+ m $ hcr $ name
236+ })
237+ names(hcr_names ) <- NULL
238+
239+ extra_columns2 <- data.frame (om = om_names , hcr = hcr_names )
240+
241+ if (! is.null(om_order ))
242+ extra_columns2 $ om <- factor (extra_columns2 $ om , levels = om_order )
243+
244+ if (! is.null(hcr_order ))
245+ extra_columns2 $ hcr <- factor (extra_columns2 $ hcr , levels = hcr_order )
246+
247+ return (listN(model_runs , extra_columns2 ))
248+
249+ }
250+
251+
252+
253+
254+
255+
256+
205257# ' Get maximum value without considering infinite values
206258# '
207259# ' Wrapper around max that ignores infinite values
0 commit comments