Skip to contents

Randomly assigns the population to k folds and returns a random sample made of elements from k-1 folds. See the Details section below for further information.

Usage

randomKm1Folds(k, N, i = NULL)

Arguments

k

number of folds

N

population size

i

(optional) integer, fold to be use as holdout data

Value

A list of length k where each element is a vector containing the indices of the sampled data.

Details

Each element in the population is randomly assigned to one of the k folds by using the randomKFolds function. If provided, i indicates the i-th fold to be considered as holdout data. If i is missing, one fold is randomly selected to be the holdout data. A random sample is then generated by removing the i-th fold and merging the remaining k - 1 folds together.

See also

Author

Alessandro Barberis

Examples

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

#Assign data to 3 folds
randomKm1Folds(N = 10, k = 3)
#> [1]  2  4  6  7  9 10