tidymodels all models fail could not find function ymd()

I am using tidymodels with a step_mutate() function where I compute age:

step_mutate(age = as.numeric((ymd("2022-12-31") - dob)/365.25))

It works fine when used in a simple workflow where I fit a logistic regression, but when I try to fit a lasso model, it returns the "All models failed" message, and in the notes, it says, "Error in dplyr::mutate():\n! Problem while computing age = as.numeric((ymd("2022-12-31") -\n dob)/365.25).\nCaused by error in ymd():\n! could not find function "ymd"". I have loaded the lubridate package and, again, this works when I use the fit() function, just not when using tune_grid() with a cross validation data.

I can't provide a reprex with the current data I'm using, but could do that with other data, if needed. For now, I will use step_date() to find the year and then compute age without using the ymd function.

for your tune_grid issue, the control_grid function has a pkgs param that is
An optional character string of R package names that should be loaded (by namespace) during parallel processing

Control aspects of the grid search process — control_grid • tune (tidymodels.org)

This topic was automatically closed 21 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.