Tidymodels error when fitting. Error: `x` and `y` must have same types and lengths

I have the following code:


rps <- tribble( ~estado,   ~comp_move,  ~move,
                "gana",    "piedra",    "papel", 
                "pierde",  "papel",     "piedra",
                "pierde",  "papel",     "piedra",
                "gana",    "tijeras",   "piedra",
                "gana",    "piedra",    "papel",  
                "pierde",  "tijeras",   "papel",  
                "gana",    "papel",     "tijeras",
                "gana",    "piedra",    "papel",  
                "pierde",  "papel",     "piedra", 
                "gana",    "tijeras",   "piedra",
                "empate",  "piedra",    "piedra", 
                "pierde",  "papel",     "piedra", 
                "empate",  "papel",     "papel",  
                "gana",    "tijeras",   "piedra")

rps <- rps %>% mutate_if(is.character,factor)
rps.split  <- initial_split(rps, prop = 0.75)
rps.rec    <- recipe(estado ~ comp_move + move, rps) %>% 
rps.rec.prep <- rps.rec %>% prep()

base.model <- rand_forest() %>%
                set_engine("ranger") %>%             

last_fit(base.model, rps.rec, rps.split)

I have also tried to use workflows

wfl <- workflow() %>%
  add_recipe(rps.rec) %>%
last_fit(wfl, split = rps.split)

When using last_fit() I get the following error:

`Error: `x` and `y` must have same types and lengths`

I have used kknn, decision_tree, random_forest and xgboost, all getting same erros. I am also getting the same error even when tuning parameters with tune_grid().

The thing is that when I use fit() function everything works fine. I know it is because I am using the model wrong but, why am I getting that error? I am new to tidymodel package.

Thanks in advance.

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.15.5

When installing the new RStudio version finally works.

Hello, I was also getting a similar error when I was rerunning the exact code in the tidymodels.org Get Started Section 5. A predictive modeling case study.
I have the R version 3.6.3 (2020-02-29) and RStudio version 1.2.1335
May I know if your problem was resolved using the same version of Rstudio?
I even tried downgrading my rsample package from 0.0.7 to 0.0.6 and I still got the same erro.
Thank you.

I had to install the new version.

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