Learn R Programming

pact (version 0.5.0)

KfoldCV: Split a dataset into k parts for k-fold cross-validation

Description

Split a dataset into k parts for k-fold cross-validation. This function is used in pact.cv to create the splits for cross-validation

Usage

KfoldCV(n, k)

Arguments

n
The sample size
k
The number of folds. k=n would mean a leave-one-out cross-validation

Value

A integer vector of same length as n. Each observation is an integer taking a value between 1 to k denoting the fold it belongs to.

Examples

Run this code
KfoldCV(15,3)
KfoldCV(15,15)

Run the code above in your browser using DataLab