diff --git a/R/action_levels.R b/R/action_levels.R index 9c42d40e1..2b90ca6cb 100644 --- a/R/action_levels.R +++ b/R/action_levels.R @@ -26,10 +26,10 @@ #' The `action_levels()` function works with the `actions` argument that is #' present in the [create_agent()] function and in every validation step #' function (which also has an `actions` argument). With it, we can provide -#' threshold *fail* levels for any combination of `warn`, `stop`, or `notify` -#' states. +#' threshold *failure* values for any combination of `warn`, `stop`, or `notify` +#' failure states. #' -#' We can react to any entrance of a state by supplying corresponding functions +#' We can react to any entering of a state by supplying corresponding functions #' to the `fns` argument. They will undergo evaluation at the time when the #' matching state is entered. If provided to [create_agent()] then the policies #' will be applied to every validation step, acting as a default for the @@ -59,7 +59,7 @@ #' `fns` for `stop` or `warn` manually then the stock functions would be #' overridden. Furthermore, if `actions` is NULL in this workflow (the default), #' **pointblank** will use a `stop_at` value of `1` (providing a detailed, -#' context-specific error message if there are any *fail* units). We can +#' context-specific error message if there are any *failing* units). We can #' absolutely suppress this automatic stopping behavior by at each validation #' step by setting `active = FALSE`. In this interactive data case, there is no #' stock function given for `notify_at`. The `notify` failure state is less @@ -72,24 +72,56 @@ #' on the entire interrogation, allowing for finer control on side effects and #' reducing potential for duplicating any side effects. #' -#' @param warn_at,stop_at,notify_at The threshold number or fraction of -#' test units that can provide a *fail* result before entering the -#' `warn`, `stop`, or `notify` failure states. If this a decimal value between -#' `0` and `1` then it's a proportional failure threshold (e.g., `0.15` -#' indicates that if 15% percent of the test units are found to *fail*, -#' then the designated failure state is entered). Absolute values starting -#' from `1` can be used instead, and this constitutes an absolute failure -#' threshold (e.g., `10` means that if 10 of the test units are found to -#' *fail*, the failure state is entered). -#' @param fns A named list of functions that is to be paired with the -#' appropriate failure states. The syntax for this list involves using failure -#' state names from the set of `warn`, `stop`, and `notify`. The functions -#' corresponding to the failure states are provided as formulas (e.g., +#' @param warn_at *Threshold value for the 'warn' failure state* +#' +#' `scalar(val>=0)` // *default:* `NULL` (`optional`) +#' +#' Either the threshold number or the threshold fraction of *failing* test +#' units that result in entering the `warn` failure state. +#' +#' @param stop_at *Threshold value for the 'stop' failure state* +#' +#' `scalar(val>=0)` // *default:* `NULL` (`optional`) +#' +#' Either the threshold number or the threshold fraction of *failing* test +#' units that result in entering the `stop` failure state. +#' +#' @param notify_at *Threshold value for the 'notify' failure state* +#' +#' `scalar(val>=0)` // *default:* `NULL` (`optional`) +#' +#' Either the threshold number or the threshold fraction of *failing* test +#' units that result in entering the `notify` failure state. +#' +#' @param fns *Functions to execute when entering failure states* +#' +#' `list` // *default:* `NULL` (`optional`) +#' +#' A named list of functions that is to be paired with the appropriate failure +#' states. The syntax for this list involves using failure state names from +#' the set of `warn`, `stop`, and `notify`. The functions corresponding to the +#' failure states are provided as formulas (e.g., #' `list(warn = ~ warning("Too many failures."))`. A series of expressions for #' each named state can be used by enclosing the set of statements with `{ }`. #' #' @return An `action_levels` object. #' +#' @section Defining threshold values: +#' +#' Any threshold values supplied for the `warn_at`, `stop_at`, or `notify_at` +#' arguments correspond to the `warn`, `stop`, and `notify` failure states, +#' respectively. A threshold value can either relates to an absolute number of +#' test units or a fraction-of-total test units that are *failing*. Exceeding +#' the threshold means entering one or more of the `warn`, `stop`, or `notify` +#' failure states. +#' +#' If a threshold value is a decimal value between `0` and `1` then it's a +#' proportional failure threshold (e.g., `0.15` indicates that if 15 percent of +#' the test units are found to be *failing*, then the designated failure state +#' is entered). Absolute values starting from `1` can be used instead, and this +#' constitutes an absolute failure threshold (e.g., `10` means that if 10 of the +#' test units are found to be *failing*, the failure state is entered). +#' #' @section Examples: #' #' For these examples, we will use the included `small_table` dataset. diff --git a/man/action_levels.Rd b/man/action_levels.Rd index 44a5c1ade..680175b3d 100644 --- a/man/action_levels.Rd +++ b/man/action_levels.Rd @@ -13,20 +13,35 @@ warn_on_fail(warn_at = 1) stop_on_fail(stop_at = 1) } \arguments{ -\item{warn_at, stop_at, notify_at}{The threshold number or fraction of -test units that can provide a \emph{fail} result before entering the -\code{warn}, \code{stop}, or \code{notify} failure states. If this a decimal value between -\code{0} and \code{1} then it's a proportional failure threshold (e.g., \code{0.15} -indicates that if 15\% percent of the test units are found to \emph{fail}, -then the designated failure state is entered). Absolute values starting -from \code{1} can be used instead, and this constitutes an absolute failure -threshold (e.g., \code{10} means that if 10 of the test units are found to -\emph{fail}, the failure state is entered).} - -\item{fns}{A named list of functions that is to be paired with the -appropriate failure states. The syntax for this list involves using failure -state names from the set of \code{warn}, \code{stop}, and \code{notify}. The functions -corresponding to the failure states are provided as formulas (e.g., +\item{warn_at}{\emph{Threshold value for the 'warn' failure state} + +\code{scalar(val>=0)} // \emph{default:} \code{NULL} (\code{optional}) + +Either the threshold number or the threshold fraction of \emph{failing} test +units that result in entering the \code{warn} failure state.} + +\item{stop_at}{\emph{Threshold value for the 'stop' failure state} + +\code{scalar(val>=0)} // \emph{default:} \code{NULL} (\code{optional}) + +Either the threshold number or the threshold fraction of \emph{failing} test +units that result in entering the \code{stop} failure state.} + +\item{notify_at}{\emph{Threshold value for the 'notify' failure state} + +\code{scalar(val>=0)} // \emph{default:} \code{NULL} (\code{optional}) + +Either the threshold number or the threshold fraction of \emph{failing} test +units that result in entering the \code{notify} failure state.} + +\item{fns}{\emph{Functions to execute when entering failure states} + +\code{list} // \emph{default:} \code{NULL} (\code{optional}) + +A named list of functions that is to be paired with the appropriate failure +states. The syntax for this list involves using failure state names from +the set of \code{warn}, \code{stop}, and \code{notify}. The functions corresponding to the +failure states are provided as formulas (e.g., \code{list(warn = ~ warning("Too many failures."))}. A series of expressions for each named state can be used by enclosing the set of statements with \code{{ }}.} } @@ -37,10 +52,10 @@ An \code{action_levels} object. The \code{action_levels()} function works with the \code{actions} argument that is present in the \code{\link[=create_agent]{create_agent()}} function and in every validation step function (which also has an \code{actions} argument). With it, we can provide -threshold \emph{fail} levels for any combination of \code{warn}, \code{stop}, or \code{notify} -states. +threshold \emph{failure} values for any combination of \code{warn}, \code{stop}, or \code{notify} +failure states. -We can react to any entrance of a state by supplying corresponding functions +We can react to any entering of a state by supplying corresponding functions to the \code{fns} argument. They will undergo evaluation at the time when the matching state is entered. If provided to \code{\link[=create_agent]{create_agent()}} then the policies will be applied to every validation step, acting as a default for the @@ -69,7 +84,7 @@ by default, indicating the reason for the failure. If you were to supply the \code{fns} for \code{stop} or \code{warn} manually then the stock functions would be overridden. Furthermore, if \code{actions} is NULL in this workflow (the default), \strong{pointblank} will use a \code{stop_at} value of \code{1} (providing a detailed, -context-specific error message if there are any \emph{fail} units). We can +context-specific error message if there are any \emph{failing} units). We can absolutely suppress this automatic stopping behavior by at each validation step by setting \code{active = FALSE}. In this interactive data case, there is no stock function given for \code{notify_at}. The \code{notify} failure state is less @@ -82,6 +97,24 @@ When using an \emph{agent}, we often opt to not use any functions in \code{fns} on the entire interrogation, allowing for finer control on side effects and reducing potential for duplicating any side effects. } +\section{Defining threshold values}{ + + +Any threshold values supplied for the \code{warn_at}, \code{stop_at}, or \code{notify_at} +arguments correspond to the \code{warn}, \code{stop}, and \code{notify} failure states, +respectively. A threshold value can either relates to an absolute number of +test units or a fraction-of-total test units that are \emph{failing}. Exceeding +the threshold means entering one or more of the \code{warn}, \code{stop}, or \code{notify} +failure states. + +If a threshold value is a decimal value between \code{0} and \code{1} then it's a +proportional failure threshold (e.g., \code{0.15} indicates that if 15 percent of +the test units are found to be \emph{failing}, then the designated failure state +is entered). Absolute values starting from \code{1} can be used instead, and this +constitutes an absolute failure threshold (e.g., \code{10} means that if 10 of the +test units are found to be \emph{failing}, the failure state is entered). +} + \section{Examples}{