powered by
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.
group
data_partition(data, training_proportion = 0.7, group = NULL, seed = 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 random number generator seed. Enter an integer (e.g. 123) so that the random sampling will be the same each time you run the function.
Other arguments passed to or from other functions.
A list of two data frames, named test and training.
test
training
Functions to rename stuff: data_rename(), data_rename_rows(), data_addprefix(), data_addsuffix()
data_rename()
data_rename_rows()
data_addprefix()
data_addsuffix()
Functions to reorder or remove columns: data_reorder(), data_relocate(), data_remove()
data_reorder()
data_relocate()
data_remove()
Functions to reshape, pivot or rotate dataframes: data_to_long(), data_to_wide(), data_rotate()
data_to_long()
data_to_wide()
data_rotate()
Functions to rescale and reverse: data_rescale(), data_reverse()
data_rescale()
data_reverse()
Functions to standardize, normalize, rank-transform: standardize(), normalize(), ranktransform(), winsorize()
standardize()
normalize()
ranktransform()
winsorize()
Split, cut and merge dataframes: data_partition(), data_cut(), data_merge()
data_partition()
data_cut()
data_merge()
Functions to find or select columns: find_columns()
find_columns()
Functions to filter rows: data_match(), data_filter()
data_match()
data_filter()
# 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