R/splitpb.R

Defines functions splitpb

Documented in splitpb

splitpb <-
function(nx, ncl, nout = NULL)
{
    i <- seq_len(nx)
    if (ncl == 0L)
        return(list())
    if (is.null(nout)) {
        k <- 1L
    } else {
        if (nout < 1L)
            stop("nout must be > 0")
        k <- max(1L, ceiling(ceiling(nx / ncl) / nout))
    }
    g <- 1L + (i - 1L) %/% as.integer(ncl * k)
    structure(split(i, g), names = NULL)
}

Try the pbapply package in your browser

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

pbapply documentation built on July 9, 2023, 7:41 p.m.