powered by
Randomly split the data indexes into nfolds folds.
nfolds
cvfolds(nfolds, datasize)
A list. Each element contains the index vector of sample data included in this fold.
list
The number of folds used in cross-validation.
The sample size.
# Given sample size 20, generate 5 folds set.seed(1212) cvfolds(5, 20) #[[1]] # [1] 6 11 14 16 #[[2]] # [1] 3 5 10 18 #[[3]] # [1] 4 7 8 19 #[[4]] # [1] 2 9 12 15 #[[5]] # [1] 1 13 17 20
Run the code above in your browser using DataLab