Skip to contents

Randomly assigns the population to k folds. See the Details section below for further information.

Usage

randomKFolds(N, k)

Arguments

N

population size

k

number of folds

Value

A vector of length N containing the fold ids.

Details

Each element in the population is randomly assigned to one of the k folds. Internally, it uses the sample function.

Author

Alessandro Barberis

Examples

#Set seed for reproducibility
set.seed(seed = 5381L)

#Assign data to 3 folds
randomKFolds(N = 10, k = 3)
#>  [1] 1 3 1 2 1 3 3 1 2 2