Q: I want to create an algorithm in R that takes a vector and outputs all the vectors that are subsets of the original I am trying to create an algorith in R that not only lists all possible subsets of a vector but also allows me to check for certain properties of these subsets, so combn is not sufficient. I tried this:
f2 = function(z)
{
  z1 = 1:z
  for (i in 1:z)
  {
    z1[i] = factorial(z)/((factorial(i-1)*(factorial(z-(i-1)))))
  }
  return(z1)
}

f3 = function(k)
{
  k1 = length(k)
  z1 = f2(k1)
  
  for (i in 2:k1)
  {
    s = combn(1:k1, i, simplify = TRUE)
    z2 = z1[k1-i+1]
    
    for (j in 1:z2)
    {
  
      for (n in 1:i)
      {
        s1[n] = s[n, j]
        print(s1)
      }
    }
  }
  
}

But this just seperates each number. Is there a different approach I can take? Thank you.
