R/frabstuff.R

Defines functions multinom

Documented in multinom

#' @export
multinom <- function(x){
    stopifnot(all(x >= 0))
    xf <- as.frab(x)
    v <- disordR::elements(frab::values(xf)) # vector of integers
    n <- disordR::elements(names(xf))        # vector of names

    if(all(x > 0)){  # NB strict
        L <- c(n, list(n))
    } else {
        L <- c(n, list(unique(names(x))))
    }
    return(hyper2(L, c(v, -sum(v))))
}

Try the hyper2 package in your browser

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

hyper2 documentation built on June 23, 2026, 5:07 p.m.