Learn R Programming

parsnip (version 0.1.4)

req_pkgs: Determine required packages for a model

Description

Determine required packages for a model

Usage

req_pkgs(x, ...)

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

# S3 method for model_fit req_pkgs(x, ...)

Arguments

x

A model specification or fit.

...

Not used.

Value

A character string of package names (if any).

Details

For a model specification, the engine must be set.

The list does not include the parsnip package.

Examples

Run this code
# NOT RUN {
should_fail <- try(req_pkgs(linear_reg()), silent = TRUE)
should_fail

linear_reg() %>%
  set_engine("glmnet") %>%
  req_pkgs()

linear_reg() %>%
  set_engine("lm") %>%
  fit(mpg ~ ., data = mtcars) %>%
  req_pkgs()
# }

Run the code above in your browser using DataLab