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