Skip to content

update_blueprint() is the correct way to alter elements of an existing blueprint object. It has two benefits over just doing blueprint$elem <- new_elem.

  • The name you are updating must already exist in the blueprint. This prevents you from accidentally updating non-existent elements.

  • The constructor for the blueprint is automatically run after the update by refresh_blueprint() to ensure that the blueprint is still valid.

Usage

update_blueprint(blueprint, ...)

Arguments

blueprint

A preprocessing blueprint.

...

Name-value pairs of existing elements in blueprint that should be updated.

Examples


blueprint <- default_xy_blueprint()

# `intercept` defaults to FALSE
blueprint
#> XY blueprint: 
#>  
#> # Predictors: 0 
#>   # Outcomes: 0 
#>    Intercept: FALSE 
#> Novel Levels: FALSE 
#>  Composition: tibble 

update_blueprint(blueprint, intercept = TRUE)
#> XY blueprint: 
#>  
#> # Predictors: 0 
#>   # Outcomes: 0 
#>    Intercept: TRUE 
#> Novel Levels: FALSE 
#>  Composition: tibble 

# Can't update non-existent elements
try(update_blueprint(blueprint, intercpt = TRUE))
#> Error in update_blueprint(blueprint, intercpt = TRUE) : 
#>   All elements to change must already exist. `intercpt` is a new field.

# Can't add non-valid elements
try(update_blueprint(blueprint, intercept = 1))
#> Error in validate_is(.x, is_bool, "bool", .x_nm, .note = "'TRUE' / 'FALSE'") : 
#>   intercept should be a bool ('TRUE' / 'FALSE'), not a numeric.