Description Usage Arguments Value Examples
View source: R/get_loading_data.R
Obtain and format PCA component data from a recipe or workflow
1 2 3 4 5 6 7 | get_loading_data(x, ...)
## S3 method for class 'recipe'
get_loading_data(x, ..., id, type = "pca")
## S3 method for class 'workflow'
get_loading_data(x, ..., id = NULL, type = "pca")
|
x |
A prepped recipe or fitted workflow that uses a recipe. The recipe
must have used at least one |
... |
An optional series of conditional statements used to filter the PCA data before plotting. See Details below. |
id |
A single numeric or character value that is used to pick the step
with the PCA results. If a single |
type |
A character value ("pca" or "pls") for the type of step to use. |
A tibble that mirrors the tidy()
method for those steps. The data
also includes a numeric component_number
and may have been changed due to
any filters supplied to ...
.
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 | library(recipes)
library(parsnip)
library(workflows)
library(ggplot2)
data("Chicago", package = "modeldata")
theme_set(theme_minimal())
## -----------------------------------------------------------------------------
train_pca <-
recipe(ridership ~ ., data = Chicago %>% dplyr::select(1:21)) %>%
step_center(all_predictors()) %>%
step_scale(all_predictors()) %>%
step_pca(all_predictors())
# or when used in a workflow
lm_workflow <-
workflow() %>%
add_model(linear_reg() %>% set_engine("lm")) %>%
add_recipe(train_pca)
## -----------------------------------------------------------------------------
train_pca <- prep(train_pca)
get_loading_data(train_pca, component_number <= 3)
get_loading_data(train_pca, component_number <= 3, value > 0)
## -----------------------------------------------------------------------------
lm_workflow <- lm_workflow %>% fit(data = Chicago)
get_loading_data(lm_workflow, component_number <= 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.