createCVgroups: Creating k-fold Cross-Validation Groups

Description Usage Arguments Value Author(s) See Also Examples

View source: R/functions_cv.R

Description

Splits a vector of observation names or indices into a list of k groups, to be used as cross-validation (CV) test groups.

Usage

1
createCVgroups(x = NULL, n = length(x), k = 10, useNames = TRUE)

Arguments

x

vector of observation ID's (character or numeric) to split into cv groups.

n

number of observations to split into cv groups. Defaults to the length of x, but can also be provided instead of x.

k

number of cross-validation groups. Must be less than or equal to n.

useNames

logical indicator of whether the names of 'x' should be used to identify observations within cv groups.

Value

A list of length k giving the IDs of observations within each test group.

Author(s)

Joshua Keller

See Also

predkmeansCVest predkmeansCVpred

Examples

1
2
3
4
5
6
7
# 5-fold groups
cv5 <- createCVgroups(n=100, k=5)
cv5

# Leave-one-out
cvLOO <- createCVgroups(n=100, k=0)
cvLOO

predkmeans documentation built on Jan. 11, 2020, 9:29 a.m.