# NOT RUN {
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)
# }
Run the code above in your browser using DataLab