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] 3 5 4 5 5 4 3 3 1 2 3 2 5 1 5 3 1 1 1 5 2 2 4 1 4 3 4 2 2 4