powered by
Splits a vector of observation names or indices into a list of k groups, to be used as cross-validation (CV) test groups.
createCVgroups(x = NULL, n = length(x), k = 10, useNames = TRUE)
vector of observation ID's (character or numeric) to split into cv groups.
number of observations to split into cv groups. Defaults to the length of x, but can also be provided instead of x.
x
number of cross-validation groups. Must be less than or equal to n.
n
logical indicator of whether the names of 'x' should be used to identify observations within cv groups.
A list of length k giving the IDs of observations within each test group.
k
predkmeansCVest predkmeansCVpred
# NOT RUN { # 5-fold groups cv5 <- createCVgroups(n=100, k=5) cv5 # Leave-one-out cvLOO <- createCVgroups(n=100, k=0) cvLOO # }
Run the code above in your browser using DataLab