How to deal with Rlang errors,

rlang
caret
#1

Greetings all,
I am running a random forest machine model using caret however I am now seeing a rlang error popping up. I am running:

  • 'dplyr’ version 0.7.8
  • caret ver. 6.0-81
  • randomForest ver. 4.6-14
  • version.string R version 3.4.4 (2018-03-15)
  • Rstudio Version 1.1.463

I could not find that much on StackOverflow that was helpful.
Any suggestions would be helpful.
Cheers

> rf1 <- train(train_transformed$Class ~ ., 
+              data = train_transformed, 
+              method = "rf",
+              tuneGrid = my_grid1, 
+              trControl = train_control)
Aggregating results
Fitting final model on full training set
Error: Column `train_transformed` not found
Call `rlang::last_error()` to see a backtrace
> rlang::last_error()
<error>
message: Column `train_transformed` not found
class:   `rlang_error`
backtrace:
 ─caret::train(...)
 ─caret:::train.formula(...)
 ─tibble:::`[.tbl_df`(data, , all.vars(Terms), drop = FALSE)
 ─tibble:::check_names_df.character(j, x)
 ─tibble:::check_names_before_after.character(j, names(x))
 ─tibble:::stopc(pluralise_msg("Column(s) ", unknown_names), " not found")
Call `summary(rlang::last_error())` to see the full backtrace
> summary(rlang::last_error())
<error>
message: Column `train_transformed` not found
class:   `rlang_error`
fields:  `message`, `trace` and `parent`
backtrace:
█
├─caret::train(...)
└─caret:::train.formula(...)
  ├─data[, all.vars(Terms), drop = FALSE]
  └─tibble:::`[.tbl_df`(data, , all.vars(Terms), drop = FALSE)
    ├─tibble:::check_names_df(j, x)
    └─tibble:::check_names_df.character(j, x)
      └─tibble:::check_names_before_after.character(j, names(x))
        └─tibble:::stopc(pluralise_msg("Column(s) ", unknown_names), " not found")
0 Likes

#2

Try this:

rf1 <- train(Class ~ ., 
+              data = train_transformed, 
+              method = "rf",
+              tuneGrid = my_grid1, 
+              trControl = train_control)

1 Like

#3

It's not an rlang error but is rlang giving you a different way of finding the error.

1 Like

#4

Greetings,
I am curious, why would caret not take my specific column call train_transformed$Class versus using Class alone. I did see the error message Column train_transformed not found but was puzzled by it. I might ask, What clues should I have been aware of that it was not a rlang error as much as a more precise error message?
Thanks

0 Likes

#5

I didn't check the syntax for caret but generally when you have a definition like data = train_transformed in packages, then the columns are defined without $.

Regarding detecting rlang errors, I'd say you are relatively unlikely to encounter them unless you are trying to apply rlang/NSE concepts. rlang is mostly designed to be hidden from the unwitting user.

2 Likes

closed #6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes