step_pca: step_pca

View source: R/api_recipes.R

step_pcaR Documentation

step_pca

Description

'StepPca' Does PCA for a set of columns. This currently is an in house function. Use at your own risk!

Usage

step_pca(
  .rec,
  terms,
  na_rm = TRUE,
  n_comp = 3,
  center = TRUE,
  scale = TRUE,
  role = "predictor",
  ...
)

Arguments

.rec

the R6 recipe object.

terms

the unquoted names of the variables to use or a selector function. terms replaces the '...' of the recipes package but requires variables to be included within 'c()'. For example to include variables x and y you would write 'c(x,y)' in the hydrorecipes package.

na_rm

logical - should NA values be removed from calculations

role

character - the name of the role

...

additional arguments

Value

an updated recipe

Examples


set.seed(1)

formula <- as.formula(x~a+b+d+e+f+g)
rows <- 1000

dat <- data.frame(x = rnorm(rows),
                  a = rnorm(rows),
                  b = rnorm(rows),
                  d = rnorm(rows),
                  e = rnorm(rows),
                  f = rnorm(rows),
                  g = rnorm(rows))

rec  = recipe(formula = formula, data = dat) |>
  step_pca(all_numeric()) |>
  plate()

jkennel/hydrorecipes documentation built on Dec. 24, 2024, 5:38 p.m.