R/contr.cum.R

Defines functions contr.cum

Documented in contr.cum

contr.cum <-
function(n) 
{
    if (is.numeric(n) && length(n) == 1) 
        levs <- 1:n
    else {
        levs <- n
        n <- length(n)
    }
    contr <- array(0, c(n, n), list(levs, levs))
    contr[col(contr) <= row(contr)] <- 1
    if (n < 2) stop(paste("Contrasts not defined for", n - 1, "degrees of freedom"))
    contr <- contr[, -1, drop = FALSE]
    contr
}

Try the Epi package in your browser

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

Epi documentation built on March 19, 2024, 3:07 a.m.