title: R Data table setkey - error some columns are not in the data.table
body: <p>I would like to use data.table <code>setkey</code> with pre-defined lists <code>id</code> and <code>categories</code>, but get an error message:</p>
  
  <pre><code>&gt; setkey(tr_id_cat_dt, id, categories)
  Error in setkeyv(x, cols, verbose = verbose) : 
    some columns are not in the data.table: categories
  </code></pre>
  
  <p>I would like all the elements of <code>id</code> and <code>categories</code> to appear as keys.</p>
  
  <p>Is this possible?</p>
  
  <hr>
  
  <p>id and categorie are lists of values, for example:</p>
  
  <pre><code>categories = c(9115L, 9909L, 3203L, 5558L, 4401L, 1703L, 1726L, 3504L, 3509L, 
  5122L, 5616L, 5619L, 2202L, 2119L, 6202L, 5824L, 799L, 4517L, 
  7205L, 706L)
  
  
  dput(head(tr_id_cat_dt))
  structure(list(id = c(86246, 86246, 86246, 86246, 86246, 86246
      ), category = c(706L, 706L, 706L, 706L, 706L, 706L)), .Names = c("id", 
      "category"), sorted = c("id", "category"), class = c("data.table", 
      "data.frame"), row.names = c(NA, -6L), .internal.selfref = &lt;pointer: 0x015424a0&gt;)
  </code></pre>