Learn R Programming

tidysynthesis (version 0.1.2)

synth_spec_recipes_api: Add, update, or remove recipe recipes from a synth_spec object

Description

Add, update, or remove recipe recipes from a synth_spec object

Usage

add_custom_steps(synth_spec, ...)

update_custom_steps(synth_spec, ...)

remove_custom_steps(synth_spec)

Value

A new synth_spec object.

A new synth_spec object with added custom steps.

A new synth_spec object with updated custom steps.

A new synth_spec object with removed custom steps.

Arguments

synth_spec

A synth_spec object

...

Optional named arguments mapping variables to lists of recipe::recipe_ function(s) from library(recipes).

Examples

Run this code

synth_spec <- synth_spec()

step1 <- function(x) {
  x |> recipes::step_center(recipes::all_predictors(), id = "center")
}

add_custom_steps(
  synth_spec = synth_spec, 
  list("vars" = c("a", "b", "c"), "steps" = step1)
)


synth_spec <- synth_spec()

step1 <- function(x) {
  x |> recipes::step_center(recipes::all_predictors(), id = "center")
}

update_custom_steps(
  synth_spec = synth_spec, 
  list("vars" = c("a", "b", "c"), "steps" = step1)
)


synth_spec <- synth_spec()

step1 <- function(x) {
  x |> recipes::step_center(recipes::all_predictors(), id = "center")
}

synth_spec <- add_custom_steps(
  synth_spec = synth_spec, 
  list("vars" = c("a", "b", "c"), "steps" = step1)
)

remove_custom_steps(synth_spec = synth_spec)

Run the code above in your browser using DataLab