title: Unique combination of all elements from two (or more) vectors
body: <p>I am trying to create a unique combination of all elements from two vectors of different size in R.</p>
  
  <p>For example, the first vector is</p>
  
  <pre><code>a &lt;- c("ABC", "DEF", "GHI")
  </code></pre>
  
  <p>and the second one is dates stored as strings currently</p>
  
  <pre><code>b &lt;- c("2012-05-01", "2012-05-02", "2012-05-03", "2012-05-04", "2012-05-05")
  </code></pre>
  
  <p>I need to create a data frame with two columns like this</p>
  
  <pre><code>&gt; data
      a          b
  1  ABC 2012-05-01
  2  ABC 2012-05-02
  3  ABC 2012-05-03
  4  ABC 2012-05-04
  5  ABC 2012-05-05
  6  DEF 2012-05-01
  7  DEF 2012-05-02
  8  DEF 2012-05-03
  9  DEF 2012-05-04
  10 DEF 2012-05-05
  11 GHI 2012-05-01
  12 GHI 2012-05-02
  13 GHI 2012-05-03
  14 GHI 2012-05-04
  15 GHI 2012-05-05
  </code></pre>
  
  <p>So basically, I am looking for a unique combination by considering all the elements of one vector (a) juxtaposed with all the elements of the second vector (b).</p>
  
  <p>An ideal solution would generalize to more input vectors.</p>
  
  <hr>
  
  <blockquote>
    <p><strong>See also:</strong><br>
    <a href="https://stackoverflow.com/questions/3993546/how-to-generate-a-matrix-of-combinations">How to generate a matrix of combinations</a>  </p>
  </blockquote>