title: Extract a column from a data.table as a vector, by position
body: <p>How do I extract a column from a data.table as a vector by its position? Below are some code snippets I have tried:</p>
  
  <pre><code>DT&lt;-data.table(x=c(1,2),y=c(3,4),z=c(5,6))
  DT
  #   x y z
  #1: 1 3 5
  #2: 2 4 6
  </code></pre>
  
  <p>I want to get this output using column position</p>
  
  <pre><code>DT$y 
  #[1] 3 4
  is.vector(DT$y)
  #[1] TRUE
  </code></pre>
  
  <p>Other way to get this output using column position    </p>
  
  <pre><code>DT[,y] 
  #[1] 3 4
  is.vector(DT[,y])
  #[1] TRUE
  </code></pre>
  
  <p>This doesn't give a vector</p>
  
  <pre><code>DT[,2,with=FALSE]
  #   y
  #1: 3
  #2: 4
  is.vector(DT[,2,with=FALSE])
  #[1] FALSE
  </code></pre>
  
  <p>Those two doesn't work:</p>
  
  <pre><code>DT$noquote(names(DT)[2]) # Doesn't work
  #Error: attempt to apply non-function
  
  DT[,noquote(names(DT)[2])] # Doesn't work
  #[1] y
  </code></pre>
  
  <p>And this doesn't give a vector:</p>
  
  <pre><code>DT[,noquote(names(DT)[2]),with=FALSE] # Not a vector
  #   y
  #1: 3
  #2: 4
  is.vector(DT[,noquote(names(DT)[2]),with=FALSE])
  #[1] FALSE
  </code></pre>