Extract train set or test set from split_df class object
extract_set(x, set = c("train", "test"))
an object of class "split_df", usually, a result of a call to split_df().
character. Specifies whether the extracted data is a train set or a test set. You can use "train" or "test".
an object of class "tbl_df".
Extract the train or test sets based on the parameters you defined when creating split_df with split_by().
library(dplyr)
# Credit Card Default Data
head(ISLR::Default)
#> default student balance income
#> 1 No No 729.5265 44361.625
#> 2 No Yes 817.1804 12106.135
#> 3 No No 1073.5492 31767.139
#> 4 No No 529.2506 35704.494
#> 5 No No 785.6559 38463.496
#> 6 No Yes 919.5885 7491.559
# Generate data for the example
sb <- ISLR::Default %>%
split_by(default)
train <- sb %>%
extract_set(set = "train")
test <- sb %>%
extract_set(set = "test")