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 50 51 52 53 54 55
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update.R
\name{update.step}
\alias{update.step}
\title{Update a recipe step}
\usage{
\method{update}{step}(object, ...)
}
\arguments{
\item{object}{A recipe \code{step}.}
\item{...}{Key-value pairs where the keys match up with names of elements
in the step, and the values are the new values to update the step with.}
}
\description{
This \code{step} method for \code{update()} takes named arguments as \code{...} who's values
will replace the elements of the same name in the actual step.
}
\details{
For a step to be updated, it must not already have been trained. Otherwise,
conflicting information can arise between the data returned from
\code{bake(object, new_data = NULL)} and the information in the step.
}
\examples{
library(modeldata)
data(biomass)
biomass_tr <- biomass[biomass$dataset == "Training",]
biomass_te <- biomass[biomass$dataset == "Testing",]
# Create a recipe using step_bs() with degree = 3
rec <- recipe(
HHV ~ carbon + hydrogen + oxygen + nitrogen + sulfur,
data = biomass_tr
) \%>\%
step_bs(carbon, hydrogen, degree = 3)
# Update the step to use degree = 4
rec2 <- rec
rec2$steps[[1]] <- update(rec2$steps[[1]], degree = 4)
# Prep both recipes
rec_prepped <- prep(rec, training = biomass_tr)
rec2_prepped <- prep(rec2, training = biomass_tr)
# Juice both to see what changed
bake(rec_prepped, new_data = NULL)
bake(rec2_prepped, new_data = NULL)
# Cannot update a recipe step that has been trained!
\dontrun{
update(rec_prepped$steps[[1]], degree = 4)
}
}
|