Skip to contents

nested() turns a model or workflow into a nested model/workflow. is_nested() checks if a model or workflow is nested.

Usage

nested(x, ...)

is_nested(x, ...)

# S3 method for default
nested(x, ...)

# S3 method for model_spec
nested(x, allow_par = FALSE, pkgs = NULL, ...)

# S3 method for nested_model
nested(x, allow_par = FALSE, pkgs = NULL, ...)

# S3 method for workflow
nested(x, allow_par = FALSE, pkgs = NULL, ...)

# S3 method for default
is_nested(x, ...)

# S3 method for model_spec
is_nested(x, ...)

# S3 method for workflow
is_nested(x, ...)

Arguments

x

A model specification or workflow.

...

Not currently used.

allow_par

A logical to allow parallel processing over nests during the fitting process (if a parallel backend is registered).

pkgs

An optional character string of R package names that should be loaded (by namespace) during parallel processing.

Value

A nested model object, or a workflow containing a nested model. For is_nested(), a logical vector of length 1.

Examples


library(parsnip)
library(workflows)

model <- linear_reg() %>%
  set_engine("lm") %>%
  nested()

model
#> Nested Model Specification
#> 
#> Inner model:
#> Linear Regression Model Specification (regression)
#> 
#> Computational engine: lm 
#> 

is_nested(model)
#> [1] TRUE

wf <- workflow() %>%
  add_model(model)

is_nested(wf)
#> [1] TRUE