diff --git a/DESCRIPTION b/DESCRIPTION index a36d2a946..1cae564dd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: portalcasting Title: Functions Used in Predicting Portal Rodent Dynamics -Version: 0.35.0 +Version: 0.37.0 Authors@R: c( person(c("Juniper", "L."), "Simonis", email = "juniper.simonis@weecology.org", role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 8e0c74d8a..ee7124c86 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,15 @@ Version numbers follow [Semantic Versioning](https://semver.org/). +# [portalcasting 0.37.0](https://github.com/weecology/portalcasting/releases/tag/v0.37.0) +*2022-04-21* + +### Building out evaluation pipeline +* starting with what is already occurring, but formalizing as such as part of an `evaluate_casts` and `evaluate_cast` pair of functions +* `evaluate_casts` function now works automatically to evaluate all the casts using `evaluate_cast`, generating the error table as it does when being used, but nothing is saved out or updated. +* there is also no filter on evaluated casts by deafult, so the output from the forecasts without observations to evaluate is a table with a single row with NaN, and then they get wrapped up into the list. + * no errors, just noteworthy + # [portalcasting 0.36.0](https://github.com/weecology/portalcasting/releases/tag/v0.36.0) *2022-04-08* diff --git a/R/create_dir.R b/R/create_dir.R index c85165047..1e7cc1824 100644 --- a/R/create_dir.R +++ b/R/create_dir.R @@ -8,6 +8,8 @@ #' #' @param settings \code{list} of controls for the directory, with defaults set in \code{\link{directory_settings}}. #' +#' @param verbose \code{logical} indicator of whether or not to print out all of the information (and thus just the tidy messages). +#' #' @return The \code{list} of directory settings \code{\link[base]{invisible}}-ly. #' #' @name directory creation @@ -31,10 +33,9 @@ create_dir <- function(main = ".", showWarnings = FALSE) - config <- write_directory_config(main = main, - settings = settings, - quiet = quiet) + write_directory_config(main = main, + settings = settings, + quiet = quiet) + - invisible(config) - } diff --git a/R/directory_configuration_file.R b/R/directory_configuration_file.R index efd303d06..32a650432 100644 --- a/R/directory_configuration_file.R +++ b/R/directory_configuration_file.R @@ -7,6 +7,8 @@ #' #' @param quiet \code{logical} indicator if progress messages should be quieted. #' +#' @param verbose \code{logical} indicator of whether or not to print out all of the information (and thus just the tidy messages). +#' #' @param main \code{character} value of the name of the main component of the directory tree. Default value (\code{"."}) puts the forecasting directory in the present locations. Nesting the forecasting directory in a folder can be done by simply adding to the \code{main} input (see \code{Examples}). #' #' @param settings \code{list} of controls for the directory, with defaults set in \code{\link{directory_settings}} that should generally not need to be altered. @@ -34,6 +36,7 @@ write_directory_config <- function (main = ".", write_yaml(x = config, file = file.path(main, settings$files$directory_config)) + invisible(config) } @@ -69,7 +72,8 @@ read_directory_config <- function (main = ".", #' update_directory_config <- function (main = ".", settings = directory_settings(), - quiet = FALSE){ + quiet = FALSE, + verbose = FALSE){ config <- read_directory_config(main = main, settings = settings, @@ -85,14 +89,13 @@ update_directory_config <- function (main = ".", config$raw$PortalData_version <- scan(file = file.path(main, settings$subs$resources, "PortalData", "version.txt"), what = "character", - quiet = TRUE) + quiet = !verbose) } - - write_yaml(x = config, file = file.path(main, settings$files$directory_config)) + invisible(config) } diff --git a/R/evaluate.R b/R/evaluate.R index 8f4fc4912..77365d6ae 100644 --- a/R/evaluate.R +++ b/R/evaluate.R @@ -1,5 +1,3 @@ - - #' @title Evaluate Forecasts #' #' @description Evaluate forecasts in the directory, based on id or group, or (if \code{cast_ids = NULL} and \code{cast_groups = NULL}, the default) \code{evaluate_casts} will evaluate all and (if \code{cast_id = NULL} and \code{cast_group = NULL}, the default), \code{evaluate_cast} will evaluate the most recent cast. @@ -8,9 +6,6 @@ #' #' @param settings \code{list} of controls for the directory, with defaults set in \code{\link{directory_settings}} that should generally not need to be altered. #' -#' @param cast_group,cast_groups \code{integer} (or integer \code{numeric}) value(s) of the cast group(s) to evaluate, as indexed within the directory in the \code{casts} sub folder. See the casts metadata file (\code{casts_metadata.csv}) for summary information. \cr -#' \code{cast_group} can only be a single value, whereas \code{cast_groups} can be multiple. -#' #' @param cast_id,cast_ids \code{integer} (or integer \code{numeric}) value(s) representing the casts of interest for evaluating, as indexed within the directory in the \code{casts} sub folder. See the casts metadata file (\code{casts_metadata.csv}) for summary information. \cr #' \code{cast_id} can only be a single value, whereas \code{cast_ids} can be multiple. #' @@ -18,22 +13,47 @@ #' #' @param verbose \code{logical} indicator of whether or not to print out all of the information (and thus just the tidy messages). #' -#' @return \code{NULL}, \code{\link[base]{invisible}}-ly. +#' @return A \code{data.frame}, or \code{list} of \code{data.frame}s. #' #' @name evaluate forecasts #' #' @export #' -evaluate_casts <- function (main = ".", - settings = directory_settings(), - cast_groups = NULL, - cast_ids = NULL, - quiet = FALSE, - verbose = FALSE) { +evaluate_casts <- function (main = ".", + settings = directory_settings(), + cast_ids = NULL, + quiet = FALSE, + verbose = FALSE) { + + + casts_to_evaluate <- select_casts(main = main, + settings = settings, + cast_ids = cast_ids) + + if (NROW(casts_to_evaluate) == 0) { + + stop("no casts available for request") + } else { + cast_ids <- casts_to_evaluate$cast_id + ncast_ids <- length(cast_ids) - invisible() + } + + out <- named_null_list(element_names = cast_ids) + + for (i in 1:ncast_ids) { + + out[[i]] <- evaluate_cast(main = main, + settings = settings, + cast_id = cast_ids[i], + quiet = quiet, + verbose = verbose) + + } + + out } @@ -42,16 +62,43 @@ evaluate_casts <- function (main = ".", #' #' @export #' -evaluate_cast <- function (main = ".", - settings = directory_settings(), - cast_group = NULL, - cast_id = NULL, - quiet = FALSE, - verbose = FALSE) { +evaluate_cast <- function (main = ".", + settings = directory_settings(), + cast_id = NULL, + quiet = FALSE, + verbose = FALSE) { + + return_if_null(cast_id) + + model_cast <- read_model_cast(main = main, + cast_id = cast_id, + settings = settings) + casts_metadata <- read_casts_metadata(main = main, + settings = settings) + cast_model <- casts_metadata$model[casts_metadata$cast_id == cast_id] + cast_model_controls <- model_controls(main = main, + models = cast_model, + settings = settings)[[cast_model]] + cast_model_response <- cast_model_controls$response + cast_tab <- read_cast_tab(main = main, + settings = settings, + cast_id = cast_id) - invisible() + cast_tab <- add_obs_to_cast_tab(main = main, + settings = settings, + cast_tab = cast_tab) + cast_tab <- add_err_to_cast_tab(main = main, + settings = settings, + cast_tab = cast_tab) + cast_tab <- add_lead_to_cast_tab(main = main, + settings = settings, + cast_tab = cast_tab) + cast_tab <- add_covered_to_cast_tab(main = main, + settings = settings, + cast_tab = cast_tab) + measure_cast_level_error(cast_tab = cast_tab) } diff --git a/R/portalcast.R b/R/portalcast.R index c48dc00fd..cc5fdfba6 100644 --- a/R/portalcast.R +++ b/R/portalcast.R @@ -46,6 +46,11 @@ portalcast <- function (main = ".", quiet = FALSE, verbose = FALSE){ +# +# the datasets here should come from the models selected +# and not as an argument ... or? maybe not? idk. think this out. +# + return_if_null(models) messageq(message_break(), "\nPreparing directory for casting\n", message_break(), "\nThis is portalcasting v", packageDescription("portalcasting", fields = "Version"), "\n", message_break(), quiet = quiet) diff --git a/R/prepare_models.R b/R/prepare_models.R index d6e3223f3..e18cd6b44 100644 --- a/R/prepare_models.R +++ b/R/prepare_models.R @@ -1,6 +1,6 @@ #' @title Read and Write Model Control Lists #' -#' @description Input/Output functions for model control lists. +#' @description Input/output functions for model control lists. #' #' @param quiet \code{logical} indicator controlling if messages are printed. #' @@ -75,6 +75,10 @@ write_model_controls <- function (main = ".", } + + + + #' @title Write Model Function Script into Directory #' #' @description Writes a model's function as a script into the defined directory for use in forecasting. \cr \cr \code{model} can be input as a \code{character} string, symbol (backquoted name), or \code{function}, as \code{\link{match.fun}} diff --git a/R/process_casts.R b/R/process_casts.R index b63b39772..3bc9aabe9 100644 --- a/R/process_casts.R +++ b/R/process_casts.R @@ -221,8 +221,8 @@ add_obs_to_cast_tab <- function (main = ".", #' @export #' read_cast_tab <- function (main = ".", - settings = directory_settings(), - cast_id = NULL) { + cast_id = NULL, + settings = directory_settings()) { if (is.null(cast_id) ){ @@ -257,8 +257,8 @@ read_cast_tab <- function (main = ".", #' @export #' read_cast_tabs <- function (main = ".", - settings = directory_settings(), - cast_ids = NULL) { + cast_ids = NULL, + settings = directory_settings()) { if (is.null(cast_ids)) { @@ -269,8 +269,8 @@ read_cast_tabs <- function (main = ".", } cast_tab <- read_cast_tab(main = main, - settings = settings, - cast_id = cast_ids[1]) + cast_id = cast_ids[1], + settings = settings) ncasts <- length(cast_ids) @@ -278,9 +278,9 @@ read_cast_tabs <- function (main = ".", for (i in 2:ncasts) { - cast_tab_i <- read_cast_tab(main = main, - settings = settings, - cast_id = cast_ids[i]) + cast_tab_i <- read_cast_tab(main = main, + cast_id = cast_ids[i], + settings = settings) cast_tab <- rbind(cast_tab, cast_tab_i) @@ -297,8 +297,8 @@ read_cast_tabs <- function (main = ".", #' @export #' read_cast_metadata <- function (main = ".", - settings = directory_settings(), - cast_id = NULL) { + cast_id = NULL, + settings = directory_settings()) { if (is.null(cast_id)) { @@ -326,8 +326,8 @@ read_cast_metadata <- function (main = ".", #' @export #' read_model_fit <- function (main = ".", - settings = directory_settings(), - cast_id = NULL) { + cast_id = NULL, + settings = directory_settings()) { if (is.null(cast_id)) { @@ -356,8 +356,8 @@ read_model_fit <- function (main = ".", #' @export #' read_model_cast <- function (main = ".", - settings = directory_settings(), - cast_id = NULL) { + cast_id = NULL, + settings = directory_settings()) { if (is.null(cast_id)) { @@ -367,17 +367,32 @@ read_model_cast <- function (main = ".", } - lpath <- paste0("cast_id_", cast_id, "_model_casts.json") - cpath <- file.path(main, settings$subs$forecasts, lpath) + lpath_json <- paste0("cast_id_", cast_id, "_model_casts.json") + cpath_json <- file.path(main, settings$subs$forecasts, lpath_json) - if (!file.exists(cpath)) { + lpath_RData <- paste0("cast_id_", cast_id, "_model_casts.RData") + cpath_RData <- file.path(main, settings$subs$forecasts, lpath_RData) - stop("cast_id does not have a model_casts file") + if (!file.exists(cpath_json)) { - } + if (!file.exists(cpath_RData)) { - read_in_json <- fromJSON(readLines(cpath)) - unserializeJSON(read_in_json) + stop("cast_id does not have a model_casts file") + + } else { + + model_casts <- NULL + load(cpath_RData) + model_casts + + } + + } else { + + read_in_json <- fromJSON(readLines(cpath_json)) + unserializeJSON(read_in_json) + + } } @@ -483,12 +498,12 @@ select_casts <- function (main = ".", #' of the model (across multiple species, for example). #' \item \code{"model_fits"}: saved out as a serialized \code{JSON} file #' via \code{\link[jsonlite]{serializeJSON}} and -#' \code{\link[jsonlite]{write_json}}, so quite flexible with respect to +#' \code{\link[jsonlite:read_json]{write_json}}, so quite flexible with respect to #' specific object structure. Saving out a \code{list} of the actual model #' fit/return objects means that models do not need to be refit later. #' \item \code{"model_casts"}: saved out as a serialized \code{JSON} file #' via \code{\link[jsonlite]{serializeJSON}} and -#' \code{\link[jsonlite]{write_json}}, so quite flexible with respect to +#' \code{\link[jsonlite:read_json]{write_json}}, so quite flexible with respect to #' specific object structure. Is used to save \code{list}s #' of predictions across multiple instances of the model. #' } diff --git a/R/rodent_species.R b/R/rodent_species.R index 1471a9029..acaec8e0e 100644 --- a/R/rodent_species.R +++ b/R/rodent_species.R @@ -109,10 +109,9 @@ rodent_species <- function (set = NULL, stop ("`type` must be `NULL`, 'all', 'base', or 'eval'") - } - if (nadot) { + if (total) { out_abb[which(out_abb == "NA")] <- "NA." diff --git a/code_development/hold_modelcontrols.R b/code_development/hold_modelcontrols.R deleted file mode 100644 index 53c586399..000000000 --- a/code_development/hold_modelcontrols.R +++ /dev/null @@ -1,52 +0,0 @@ - - list( - AutoArima = list(metadata = list(name = "AutoArima", - descriptor = "classic model, all species, focal species"), - fun = "AutoArima", - args = NULL, - datasets = c("all", "controls", "exclosures", "dm_controls")), - ESSS = list(metadata = list(name = "ESSS", - descriptor = "classic model, all species, focal species"), - fun = "ESSS", - args = NULL, - datasets = c("all_interp", "controls_interp", "exclosures_interp", "dm_controls_interp")), - NaiveArima = list(metadata = list(name = "NaiveArima", - descriptor = "classic model, all species, focal species"), - fun = "NaiveArima", - args = NULL, - datasets = c("all", "controls", "exclosures", "dm_controls")), - nbGARCH = list(metadata = list(name = "nbGARCH", - descriptor = "classic model, all species, focal species"), - fun = "nbGARCH", - args = NULL, - datasets = c("all_interp", "controls_interp", "exclosures_interp", "dm_controls_interp")), - nbsGARCH = list(metadata = list(name = "nbsGARCH", - descriptor = "classic model, all species, focal species"), - fun = "nbsGARCH", - args = NULL, - datasets = c("all_interp", "controls_interp", "exclosures_interp", "dm_controls_interp")), - pevGARCH = list(metadata = list(name = "pevGARCH", - descriptor = "classic model, all species, focal species"), - fun = "pevGARCH", - datasets = c("all_interp", "controls_interp", "exclosures_interp", "dm_controls_interp"), - args = list(lag = 6)), -# simplexEDM = list(metadata = list(name = "simplexEDM", -# descriptor = "population model, all species, focal species"), -# fun = "simplexEDM", -# datasets = c("all_interp", "controls_interp", "exclosures_interp", "dm_controls_interp"), -# args = list(max_E = 7)), -# GPEDM = list(metadata = list(name = "GPEDM", -# descriptor = "population model, all species, focal species"), -# fun = "GPEDM", -# datasets = c("all_interp", "controls_interp", "exclosures_interp", "dm_controls_interp"), -# args = list(max_E = 7)), - jags_RW = list(metadata = list(name = "jags_RW", - descriptor = "population model, focal species"), - fun = "jags_RW", - datasets = c("dm_controls"), - args = list(control_runjags = runjags_control())), - jags_logistic = list(metadata = list(name = "jags_logistic", - descriptor = "population model, focal species"), - fun = "jags_logistic", - datasets = c("dm_controls"), - args = list(control_runjags = runjags_control()))) diff --git a/code_development/hold_rodentcontrols.R b/code_development/hold_rodentcontrols.R deleted file mode 100644 index dc3a33771..000000000 --- a/code_development/hold_rodentcontrols.R +++ /dev/null @@ -1,200 +0,0 @@ -prefab_rodent_dataset_controls <- function(interpolate = NULL) { - out <- list( - all = list(metadata = list(name = "all", - descriptor = "classic dataset, all plots combined"), - fun = "prep_rodent_dataset", - args = list(name = "all", - species = base_species(), - total = TRUE, - interpolate = FALSE, - clean = FALSE, - type = "Rodents", - level = "Site", - plots = "all", - treatment = NULL, - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_all.csv")), - all_interp = list(metadata = list(name = "all_interp", - descriptor = "classic dataset, all plots combined, interpolated for models that cannot have missing data"), - fun = "prep_rodent_dataset", - args = list(name = "all_interp", - species = base_species(), - total = TRUE, - interpolate = TRUE, - clean = FALSE, - type = "Rodents", - level = "Site", - plots = "all", - treatment = NULL, - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_all_interp.csv")), - controls = list(metadata = list(name = "controls", - descriptor = "classic dataset, control plots combined"), - fun = "prep_rodent_dataset", - args = list(name = "controls", - species = base_species(), - total = TRUE, - interpolate = FALSE, - clean = FALSE, - type = "Rodents", - level = "Treatment", - plots = "Longterm", - treatment = "control", - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_controls.csv")), - controls_interp = list(metadata = list(name = "controls_interp", - descriptor = "classic dataset, control plots combined, interpolated for models that cannot have missing data"), - fun = "prep_rodent_dataset", - args = list(name = "controls_interp", - species = base_species(), - total = TRUE, - interpolate = TRUE, - clean = FALSE, - type = "Rodents", - level = "Treatment", - plots = "Longterm", - treatment = "control", - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_controls_interp.csv")), - exclosures = list(metadata = list(name = "exclosures", - descriptor = "classic dataset, exclosure plots combined"), - fun = "prep_rodent_dataset", - args = list(name = "exclosures", - species = base_species(), - total = TRUE, - interpolate = FALSE, - clean = FALSE, - type = "Rodents", - level = "Treatment", - plots = "Longterm", - treatment = "exclosure", - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_exclosures.csv")), - exclosures_interp = list(metadata = list(name = "exclosures_interp", - descriptor = "classic dataset, exclosure plots combined, interpolated for models that cannot have missing data"), - fun = "prep_rodent_dataset", - args = list(name = "exclosures_interp", - species = base_species(), - total = TRUE, - interpolate = TRUE, - clean = FALSE, - type = "Rodents", - level = "Treatment", - plots = "Longterm", - treatment = "exclosure", - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_exclosures_interp.csv")), - dm_controls = list(metadata = list(name = "dm_controls", - descriptor = "DM only, control plots combined"), - fun = "prep_rodent_dataset", - args = list(name = "dm_controls", - species = "DM", - total = FALSE, - interpolate = FALSE, - clean = FALSE, - type = "Rodents", - level = "Treatment", - plots = "Longterm", - treatment = "control", - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_dm_controls.csv")), - dm_controls_interp = list(metadata = list(name = "dm_controls_interp", - descriptor = "DM only, control plots combined, interpolated for models that cannot have missing data"), - fun = "prep_rodent_dataset", - args = list(name = "dm_controls_interp", - species = "DM", - total = FALSE, - interpolate = TRUE, - clean = FALSE, - type = "Rodents", - level = "Treatment", - plots = "Longterm", - treatment = "control", - min_plots = 24, - min_traps = 1, - output = "abundance", - fillweight = FALSE, - unknowns = FALSE, - time = "newmoon", - na_drop = FALSE, - zero_drop = TRUE, - effort = TRUE, - filename = "rodents_dm_controls_interp.csv"))) - - if (is.null(interpolate)) { - - out - - } else { - - dsnames <- names(out) - - if (interpolate) { - - out[grepl("_interp", dsnames)] - - } else { - - out[!grepl("_interp", dsnames)] - - } - - } - -} \ No newline at end of file diff --git a/code_development/notes.R b/code_development/notes.R index f3270abc1..cfa073c5b 100644 --- a/code_development/notes.R +++ b/code_development/notes.R @@ -4,7 +4,26 @@ devtools::document() devtools::load_all() -main <- "./portalcasting" +main <- "~/portalcasting" + + +setup_production(main = main) + +# +# to do +# +# in portalcast and cast +# datasets should come from the models' via their controls +# + + + + + + + + + diff --git a/man/directory-creation.Rd b/man/directory-creation.Rd index ca40aa0e1..1e0af117e 100644 --- a/man/directory-creation.Rd +++ b/man/directory-creation.Rd @@ -13,6 +13,8 @@ create_dir(main = ".", settings = directory_settings(), quiet = FALSE) \item{settings}{\code{list} of controls for the directory, with defaults set in \code{\link{directory_settings}}.} \item{quiet}{\code{logical} indicator if progress messages should be quieted.} + +\item{verbose}{\code{logical} indicator of whether or not to print out all of the information (and thus just the tidy messages).} } \value{ The \code{list} of directory settings \code{\link[base]{invisible}}-ly. diff --git a/man/directory_configuration_file.Rd b/man/directory_configuration_file.Rd index 439e16020..776b30b18 100644 --- a/man/directory_configuration_file.Rd +++ b/man/directory_configuration_file.Rd @@ -22,7 +22,8 @@ read_directory_config( update_directory_config( main = ".", settings = directory_settings(), - quiet = FALSE + quiet = FALSE, + verbose = FALSE ) } \arguments{ @@ -31,6 +32,8 @@ update_directory_config( \item{settings}{\code{list} of controls for the directory, with defaults set in \code{\link{directory_settings}} that should generally not need to be altered.} \item{quiet}{\code{logical} indicator if progress messages should be quieted.} + +\item{verbose}{\code{logical} indicator of whether or not to print out all of the information (and thus just the tidy messages).} } \value{ \code{list} of directory configurations, \code{\link[base]{invisible}}-ly. diff --git a/man/evaluate-forecasts.Rd b/man/evaluate-forecasts.Rd index 9936cadbc..cdbddda80 100644 --- a/man/evaluate-forecasts.Rd +++ b/man/evaluate-forecasts.Rd @@ -9,7 +9,6 @@ evaluate_casts( main = ".", settings = directory_settings(), - cast_groups = NULL, cast_ids = NULL, quiet = FALSE, verbose = FALSE @@ -18,7 +17,6 @@ evaluate_casts( evaluate_cast( main = ".", settings = directory_settings(), - cast_group = NULL, cast_id = NULL, quiet = FALSE, verbose = FALSE @@ -33,14 +31,11 @@ evaluate_cast( \item{verbose}{\code{logical} indicator of whether or not to print out all of the information (and thus just the tidy messages).} -\item{cast_group, cast_groups}{\code{integer} (or integer \code{numeric}) value(s) of the cast group(s) to evaluate, as indexed within the directory in the \code{casts} sub folder. See the casts metadata file (\code{casts_metadata.csv}) for summary information. \cr -\code{cast_group} can only be a single value, whereas \code{cast_groups} can be multiple.} - \item{cast_id, cast_ids}{\code{integer} (or integer \code{numeric}) value(s) representing the casts of interest for evaluating, as indexed within the directory in the \code{casts} sub folder. See the casts metadata file (\code{casts_metadata.csv}) for summary information. \cr \code{cast_id} can only be a single value, whereas \code{cast_ids} can be multiple.} } \value{ -\code{NULL}, \code{\link[base]{invisible}}-ly. +A \code{data.frame}, or \code{list} of \code{data.frame}s. } \description{ Evaluate forecasts in the directory, based on id or group, or (if \code{cast_ids = NULL} and \code{cast_groups = NULL}, the default) \code{evaluate_casts} will evaluate all and (if \code{cast_id = NULL} and \code{cast_group = NULL}, the default), \code{evaluate_cast} will evaluate the most recent cast. diff --git a/man/read-and-write-model-controls.Rd b/man/read-and-write-model-controls.Rd index b53166edb..428fe7d5e 100644 --- a/man/read-and-write-model-controls.Rd +++ b/man/read-and-write-model-controls.Rd @@ -38,5 +38,5 @@ write_model_controls( \code{list} of \code{models}' control \code{list}s, \code{\link[base]{invisible}}-ly for \code{write_model_controls}. } \description{ -Input/Output functions for model control lists. +Input/output functions for model control lists. } diff --git a/man/read-cast-output.Rd b/man/read-cast-output.Rd index 3eb0ce562..a61ccbe4e 100644 --- a/man/read-cast-output.Rd +++ b/man/read-cast-output.Rd @@ -9,15 +9,15 @@ \alias{read_model_cast} \title{Read in Cast Output From a Given Cast} \usage{ -read_cast_tab(main = ".", settings = directory_settings(), cast_id = NULL) +read_cast_tab(main = ".", cast_id = NULL, settings = directory_settings()) -read_cast_tabs(main = ".", settings = directory_settings(), cast_ids = NULL) +read_cast_tabs(main = ".", cast_ids = NULL, settings = directory_settings()) -read_cast_metadata(main = ".", settings = directory_settings(), cast_id = NULL) +read_cast_metadata(main = ".", cast_id = NULL, settings = directory_settings()) -read_model_fit(main = ".", settings = directory_settings(), cast_id = NULL) +read_model_fit(main = ".", cast_id = NULL, settings = directory_settings()) -read_model_cast(main = ".", settings = directory_settings(), cast_id = NULL) +read_model_cast(main = ".", cast_id = NULL, settings = directory_settings()) } \arguments{ \item{main}{\code{character} value of the name of the main component of the directory tree.} diff --git a/man/save_cast_output.Rd b/man/save_cast_output.Rd index ed1b898f5..9f618685d 100644 --- a/man/save_cast_output.Rd +++ b/man/save_cast_output.Rd @@ -41,12 +41,12 @@ Currently, four generalized output components are recognized and indicated by th of the model (across multiple species, for example). \item \code{"model_fits"}: saved out as a serialized \code{JSON} file via \code{\link[jsonlite]{serializeJSON}} and - \code{\link[jsonlite]{write_json}}, so quite flexible with respect to + \code{\link[jsonlite:read_json]{write_json}}, so quite flexible with respect to specific object structure. Saving out a \code{list} of the actual model fit/return objects means that models do not need to be refit later. \item \code{"model_casts"}: saved out as a serialized \code{JSON} file via \code{\link[jsonlite]{serializeJSON}} and - \code{\link[jsonlite]{write_json}}, so quite flexible with respect to + \code{\link[jsonlite:read_json]{write_json}}, so quite flexible with respect to specific object structure. Is used to save \code{list}s of predictions across multiple instances of the model. } diff --git a/tests/testthat/test-22-evaluate.R b/tests/testthat/test-22-evaluate.R index 96b4f0be1..32ecc09d4 100644 --- a/tests/testthat/test-22-evaluate.R +++ b/tests/testthat/test-22-evaluate.R @@ -1,15 +1,18 @@ context(desc = "evaluate functions") +main <- "./testing" + test_that(desc = "evaluate_casts evaluates casts", { - expect_null(evaluate_casts()) + expect_is(evaluate_casts(main = main, cast_ids = 1:2), "list") }) test_that(desc = "evaluate_cast evaluates cast", { - expect_null(evaluate_cast()) + expect_null(evaluate_cast(main = main)) + expect_is(evaluate_cast(main = main, cast_id = 1), "data.frame") })