R/permutations.R

Defines functions permutations

Documented in permutations

permutations <- function(x) {
    if (length(x) == 1) {
        return(x)
    }
    
    res <- matrix(nrow = 0, ncol = length(x))
    for (i in seq_along(x)) {
        res <- rbind(res, cbind(x[i], Recall(x[-i])))
    }

    return(res)
}

Try the admisc package in your browser

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

admisc documentation built on Sept. 12, 2024, 6:27 a.m.