title: R data table unique record count based on all combination of a given list of values from 2 columns
body: <p>I have a <code>data.table</code> in R as below</p>
  
  <pre><code>Col1          Col2         
  Col1Value1    Col2Value1   
  Col1Value1    Col2Value2
  Col1Value1    Col2Value3
  Col1Value2    Col2Value1   
  Col1Value2    Col2Value3
  Col1Value3    Col2Value1
  Col1Value3    Col2Value2
  Col1Value3    Col2Value3
  </code></pre>
  
  <p>I want to get the count of records for each combination between given values in <code>Col1 - (Col1Value1,Col1Value2)</code> against values in <code>Col2 - Col1(Col2Value1,Col2Value2)</code> and if no records for a combination then return 0</p>
  
  <p><code>counts &lt;- dt[, length(unique(Col2)), by=.(Col1, Col2)]</code></p>
  
  <p>The above code returns all combinations, but</p>
  
  <pre><code>- A combination with 0 records are not returned
  - Not able to restrict to a given list
  </code></pre>
  
  <p>Expected result</p>
  
  <pre><code>Col1           Col2        Count
  Col1Value1     Col2Value1    1
  Col1Value1     Col2Value2    1
  Col1Value2     Col2Value1    1
  Col1Value2     Col2Value2    0
  </code></pre>