Skip to contents

Utility function to create folds of data, used in cross-validation proceidures. The implementation is from the gbex R package

Usage

make_folds(y, num_folds, stratified = FALSE)

Arguments

y

Numerical vector of observations

num_folds

Number of folds to create.

stratified

Logical value. If TRUE, the folds are stratified along rank(y).

Value

Vector of indices of the assigned folds for each observation.

Examples

make_folds(rnorm(30), 5)
#>  [1] 1 3 2 3 1 3 4 1 5 3 2 2 4 5 1 2 3 1 2 5 4 3 4 4 1 5 5 4 5 2