R/cv.split.R

Defines functions cv.split

Documented in cv.split

cv.split <- function( y, fold )
{
    n <- length(y)
    group <- table(y)
    x <- c()
    for ( i in 1:length(group) )
    {
        x.group <- c(1:n)[ y==names(group)[i] ] 
        x <- c( x, sample(x.group) )
    }
    foldi <- split( x, rep(1:fold, length = n) )
    
    return( foldi )
}

Try the spls package in your browser

Any scripts or data that you put into this service are public.

spls documentation built on May 6, 2019, 1:09 a.m.