
Last chance! 50% off unlimited learning
Sale ends in
Creates a training and a test set based on a dataframe. Can also be stratified (i.e., evenly spread a given factor) using the group
argument.
data_partition(x, training_proportion = 0.7, group = NULL)
A data frame, or an object that can be coerced to a data frame.
The proportion (between 0 and 1) of the training set. The remaining part will be used for the test set.
A character vector indicating the name(s) of the column(s) used for stratified partitioning.
A list of two data frames, named test
and training
.
# NOT RUN {
df <- iris
df$Smell <- rep(c("Strong", "Light"), 75)
data_partition(df)
data_partition(df, group = "Species")
data_partition(df, group = c("Species", "Smell"))
# }
Run the code above in your browser using DataLab