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)
}
YuLab-SMU/yulab.utils documentation built on April 14, 2025, 1:54 p.m.