step_scale: step_scale

View source: R/api_recipes.R

step_scaleR Documentation

step_scale

Description

Adds a step to scale a data column(s)

Usage

step_scale(
  .rec,
  terms,
  role = "predictor",
  skip = FALSE,
  na_rm = TRUE,
  fun = collapse::fsd,
  n_sd = 1L,
  keep_original_cols = FALSE,
  ...
)

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.

role

character - the name of the role

skip

logical - should the step be skipped

na_rm

logical - should NA values be removed from calculations

fun

function - the function that is applied to a list or columns of a data.frame like object.

n_sd

numeric - number of standard deviations for the scaling

keep_original_cols

logical - keep the original columns or replace them

...

additional arguments

Value

an updated recipe

Examples


dat <- data.frame(x = rnorm(10), y = rnorm(10))

rec <- recipe(y~x, data = dat) |>
       step_scale(x)


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