title: Extract a column by reference from a data.table as a vector
body: <p>I would like to extract the column values from a <code>data.table</code> object specifying the column name using a variable. For example:</p>
  
  <pre><code>DT &lt;- data.table(x = c(1, 2), y = c(3, 4), z = c(5, 6))
  col &lt;- "z"
  </code></pre>
  
  <p>then </p>
  
  <pre><code>&gt; is.vector(DT[, col, with = F])
  [1] FALSE
  </code></pre>
  
  <p>because it returns a <code>data.table</code> object instead.</p>
  
  <p>I have tried also: <code>is.vector(DT[, (col), with = F])</code> and also: <code>is.vector(DT[, ..col])</code> with the same result. I have tried other possibilities that produce an error.</p>
  
  <p>Using directly the variable name works:</p>
  
  <pre><code>&gt; is.vector(DT[, z])
  [1] TRUE
  </code></pre>
  
  <p>I found this <a href="https://stackoverflow.com/questions/20043313/extract-a-column-from-a-data-table-as-a-vector-by-position">post</a>, that solves it using column position but not using a name by reference:</p>
  
  <pre><code>&gt; is.vector(DT[[3]])
  [1] TRUE
  </code></pre>
  
  <p>I didn't find an explicit reference about this particular case in the <code>data.table</code> <a href="https://rawgit.com/wiki/Rdatatable/data.table/vignettes/datatable-intro.html" rel="nofollow noreferrer">documentation</a>. I am sure it is an easy way to do it, but I didn't find how.</p>