A reproducible example, called a reprex will attract more and likely better answers.
Here's an example:
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(purrr))
suppressPackageStartupMessages(library(rsample))
pdata <- iris
pdata_split <- initial_split(pdata, 0.9)
training_data <- training(pdata_split)
testing_data <- testing(pdata_split)
train_cv <- vfold_cv(training_data, 5, strata = Species) %>% mutate(train = map(splits, ~training(.x)), validate = map(splits, ~testing(.x)))
(model_ranger <- train_cv %>% crossing(mtry = c(1,2)))
#> # A tibble: 10 x 5
#> splits id train validate mtry
#> <named list> <chr> <named list> <named list> <dbl>
#> 1 <split [107/29]> Fold1 <df[,5] [107 × 5]> <df[,5] [29 × 5]> 1
#> 2 <split [107/29]> Fold1 <df[,5] [107 × 5]> <df[,5] [29 × 5]> 2
#> 3 <split [108/28]> Fold2 <df[,5] [108 × 5]> <df[,5] [28 × 5]> 1
#> 4 <split [108/28]> Fold2 <df[,5] [108 × 5]> <df[,5] [28 × 5]> 2
#> 5 <split [109/27]> Fold3 <df[,5] [109 × 5]> <df[,5] [27 × 5]> 1
#> 6 <split [109/27]> Fold3 <df[,5] [109 × 5]> <df[,5] [27 × 5]> 2
#> 7 <split [110/26]> Fold4 <df[,5] [110 × 5]> <df[,5] [26 × 5]> 1
#> 8 <split [110/26]> Fold4 <df[,5] [110 × 5]> <df[,5] [26 × 5]> 2
#> 9 <split [110/26]> Fold5 <df[,5] [110 × 5]> <df[,5] [26 × 5]> 1
#> 10 <split [110/26]> Fold5 <df[,5] [110 × 5]> <df[,5] [26 × 5]> 2
Created on 2020-01-08 by the reprex package (v0.3.0)
It's hard to figure out the source of the error without knowing the actual pdata
input or a faux-pdata
with the same structure.