title: Function to generate ordered combinations
body: <p>What R command generates all possible ordered combinations of length k?</p>
  
  <p>For example from this vector:  </p>
  
  <pre><code>a,b,c,d  
  </code></pre>
  
  <p>It want to generate all combinations of length 3 but only those ones where the order is conserved:  </p>
  
  <pre><code>a,b,c  
  a,b,d  
  a,c,d  
  b,c,d 
  </code></pre>
  
  <p>Or If I have this vector  </p>
  
  <pre><code>a,b,7,d,e
  </code></pre>
  
  <p>I want to do the same for length 2:  </p>
  
  <pre><code>a,b  
  a,7  
  a,d  
  a,e  
  b,7  
  b,d  
  b,e  
  7,d  
  7,e  
  d,e
  </code></pre>
  
  <p>combn doesn't work here because it gives you all possible combinations including reversed ones such as<br>
  c,b<br>
  In simple cases I could try to do it with expand.grid but both methods would need further processing.<br>
  Maybe there is a base function (or package) able to do what I want or even accepting more complex conditions.  </p>
  
  <p>PD: When I say "ordered" I'm speaking about the order of appearance in the starting vector. I don't mean the typographic order, though in my example they are the same.</p>