I am trying to move away from subsetting R objects with [] syntax and instead use tidyverse functions in support of tidy models. Here are two examples of objects with lists and lists in lists. I can see what I want to extract but can't seem to get the functions unnest(), pluck(), pull() or map to output a tibble or dataframe.
Example 1 - I would like to return a tibble of the parameter ranges of a list of parameters, and have these in a tibble:
p <- list(min_n(), trees(), learn_rate())
p1 <- dials::parameters(p)
the result I'd like is x <- as.tibble(p1[[6]][[1]][[2]]) , is there a way to represent this in tidyverse syntax?
Example 2 - I would like to return a row bound output of resampling of df as a tibble showing the split for each fold.
Target <- as.factor(sample(c("A", "B"), 100, replace = TRUE))
Other <- as.factor(sample(c("AA", "BB", "CCC", "DDD"), 100, replace = TRUE))
Numb1 <- sample(1:100, 100, replace = TRUE)
Numb2 <- sample(1:100, 100, replace = TRUE)
df <- data.frame(Target, Other, Numb1, Numb2)
res <- vfold_cv(df, v = 5, repeats = 1, strata = Target)
the result I'd like is a tibble with all fold data stacked, y <- res[[1]][[1]][["data"]] for each of the 5 folds.
I see the extractor help functions but would much rather understand and use base tidyverse functions if possible.
Suggestions are appreciated.