title: Cross join in data.table within a function
body: <p>I'd like to create a cross join <code>data.table</code> within a function. Say, we've got a vector <code>vals &lt;- c("yes", "no")</code>. Now this one works: <code>CJ(vals, vals)</code>. However, depending on the function input, I might need to create e.g. <code>CJ(vals, vals, vals, vals)</code> instead. Something like </p>
  
  <pre><code>vals &lt;- c("yes", "no")
  n &lt;- 4
  CJ(rep(vals, n))
  </code></pre>
  
  <p>obviously wouldn't work. How can I specify the vectors for cross-joining in a flexible manner? </p>