title: How do I find all possible subsets of a set iteratively in R?
body: <p>So I know that the following command would store all possible combinations of a desired length y in a list, where <code>y &lt; j</code>:</p>
  
  <pre><code> lapply(y, function(x) combn(j,x))
  </code></pre>
  
  <p>But I don't want them all to be stored in a list because later on I will be accessing them only once so it's not efficient to store them in memory. Is there a way where I can just produce each combination in some sort of a loop or something, and then after I'm done performing a calculation, it would just give me the next combination? So basically I want to produce the combinations iteratively instead of storing them first.</p>
  
  <p>So in pseudo code, what i'd like to have is:</p>
  
  <pre><code>#loop that will generate each possible combination one by one
  loop{
    operation that uses combination
  }
  </code></pre>