k_fold: K-fold sampling

View source: R/trans_sample.R

k_foldR Documentation

K-fold sampling

Description

k-fold partition of a dataset using a sampling method

Usage

k_fold(obj, data, k)

Arguments

obj

an object representing the sampling method

data

dataset to be partitioned

k

number of folds

Value

returns a list of k data frames

Examples

#using random sampling
sample <- sample_random()

# preparing dataset into four folds
folds <- k_fold(sample, iris, 4)

# distribution of folds
tbl <- NULL
for (f in folds) {
 tbl <- rbind(tbl, table(f$Species))
}
head(tbl)

daltoolbox documentation built on Nov. 3, 2024, 9:06 a.m.