Skip to content

Create informative error message if a model engine package is not installed #292

Closed
@markbneal

Description

@markbneal

Following the example at https://rviews.rstudio.com/2019/06/19/a-gentle-intro-to-tidymodels/, running a model generates uninformative errors if the engine is not installed:

 iris_ranger <- rand_forest(trees = 100, mode = "classification") %>%
  set_engine("ranger") %>%
  fit(Species ~ ., data = iris_training)

If ranger not installed:

# Error in parse(text = text, keep.source = FALSE) : 
#   <text>:5:5: unexpected 'else'
# 4:     }
# 5:     else
#   ^

and for:

iris_rf <-  rand_forest(trees = 100, mode = "classification") %>%
  set_engine("randomForest") %>%
  fit(Species ~ ., data = iris_training)

If randomForest not installed:

# Error in as.data.frame.default(x) : 
#   cannot coerce class ‘c("rand_forest", "model_spec")’ to a data.frame

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions