Description Usage Arguments Value See Also Examples
Creates a specification of a recipe step that will compute one or more linear combinations of a set of numeric variables according to a userspecified transformation matrix.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 
recipe 
recipe object to which the step will be added. 
... 
one or more selector functions to choose which variables will be
used to compute the components. See 
transform 
function whose first argument 
num_comp 
number of components to derive. The value of 
options 
list of elements to be added to the step object for use in the

center, scale 
logicals indicating whether to mean center and standard deviation scale the original variables prior to deriving components, or functions or names of functions for the centering and scaling. 
replace 
logical indicating whether to replace the original variables. 
prefix 
character string prefix added to a sequence of zeropadded integers to generate names for the resulting new variables. 
role 
analysis role that added step variables should be assigned. By default, they are designated as model predictors. 
skip 
logical indicating whether to skip the step when the recipe is
baked. While all operations are baked when 
id 
unique character string to identify the step. 
x 

An updated version of recipe
with the new step added to the
sequence of existing steps (if any). For the tidy
method, a tibble
with columns terms
(selectors or variables selected), weight
of each variable in the linear transformations, and name
of the new
variable names.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  library(recipes)
pca_mat < function(x, step) {
prcomp(x)$rotation[, 1:step$num_comp, drop = FALSE]
}
rec < recipe(rating ~ ., data = attitude)
lincomp_rec < rec %>%
step_lincomp(all_numeric(), all_outcomes(),
transform = pca_mat, num_comp = 3, prefix = "PCA")
lincomp_prep < prep(lincomp_rec, training = attitude)
lincomp_data < bake(lincomp_prep, attitude)
pairs(lincomp_data, lower.panel = NULL)
tidy(lincomp_rec, number = 1)
tidy(lincomp_prep, number = 1)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.