1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
## Overall Wrappers to Make New `step_X` or `check_Y` Objects
#'
#' `step` sets the class of the `step` and `check` is for checks.
#'
#' @param subclass A character string for the resulting class. For example,
#' if `subclass = "blah"` the step object that is returned has class
#' `step_blah` or `check_blah` depending on the context.
#' @param ... All arguments to the operator that should be returned.
#' @param .prefix Prefix to the subclass created.
#' @keywords internal
#' @concept preprocessing
#' @return An updated step or check with the new class.
#' @export
step <- function(subclass, ..., .prefix = "step_") {
structure(list(...),
class = c(paste0(.prefix, subclass), "step"))
}
#' @rdname step
#' @export
check <- function(subclass, ..., .prefix = "check_") {
structure(list(...),
class = c(paste0(.prefix, subclass), "check"))
}
#' Add a New Operation to the Current Recipe
#'
#' `add_step` adds a step to the last location in the recipe.
#' `add_check` does the same for checks.
#'
#' @param rec A [recipe()].
#' @param object A step or check object.
#' @keywords datagen
#' @concept preprocessing
#' @return A updated [recipe()] with the new operation in the last slot.
#' @export
add_step <- function(rec, object) {
rec$steps[[length(rec$steps) + 1]] <- object
rec
}
#' @rdname add_step
#' @export
add_check <- function(rec, object) {
rec$steps[[length(rec$steps) + 1]] <- object
rec
}
|