R/combinations.R

Defines functions combinations

Documented in combinations

#' all possible combinations of n sets
#'
#' @title combinations
#' @param n number of sets
#' @return a list of all combinations
#' @importFrom utils combn
#' @export
combinations <- function(n){
  l <- lapply(seq_len(n), function(x){
    m <- combn(n,x)
    mat2list(m)
  })
  unlist(l, recursive = F)
}

Try the yulab.utils package in your browser

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

yulab.utils documentation built on Sept. 20, 2023, 9:06 a.m.