Learn R Programming

modeltuning (version 0.1.3)

cv_split: Generate cross-validation fold indices

Description

Splits row indices of a data frame or matrix into k folds for cross-validation.

Usage

cv_split(data, v = 5, seed = NULL)

Value

A list of length v, where each element is a vector of row indices for that fold.

Arguments

data

A data frame or matrix.

v

Integer. Number of folds. Defaults to 5.

seed

Optional integer. Random seed for reproducibility.

Examples

Run this code
folds <- cv_split(mtcars, v = 5)
str(folds)

Run the code above in your browser using DataLab