R/powerset.R

Defines functions powerset

powerset <- function(set) {
  n <- length(set)
  if (n == 0) return(list(c()))
  indices <- sapply(0:(2^n-1), function(p) as.logical(intToBits(p)[1:n]), simplify = FALSE)
  subsets <- lapply(indices, function(i) set[i])
  return(subsets)
}

Try the causaleffect package in your browser

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

causaleffect documentation built on July 14, 2022, 5:07 p.m.