I´m trying to fit several models and wanted to use a tibble to organize all the data, however I´m stuck at trying to split each dataset
here is the example:
library(tidyverse)
library(tidymodels)
my_data <-crossing(labels = c("A", "B", "C", "D"),
first_var = seq(1,100, 200),
second_var = rnorm(100, 0.25, 0.02))
my_data_nested <- my_data %>% nest(vars = c(first_var, second_var))
# A tibble: 4 x 2
labels vars
<chr> <list>
1 A <tibble [100 x 2]>
2 B <tibble [100 x 2]>
3 C <tibble [100 x 2]>
4 D <tibble [100 x 2]>
I´d like to add a column with the "initial_split" from the rsample package
when I try:
my_data_i_split <- my_data_nested %>% map(vars ~ initial_split(.x))
Error: Can't convert a two-sided formula to a function
Run `rlang::last_error()` to see where the error occurred.
I get this error that goes well above my r knowledge.