title: R - subset data frame column using names in vector list
body: <p>Is it possible to subset data frame columns  (into new df) using column names stored in the array of column names - like in c("col1", "col9", "col6")? I know I can reference one column in df using df[[colname]] syntax but it does not let me do it for multiple columns:</p>
  
  <pre><code>df
     X1 X2 X3
  1:  a  1  3
  2:  b  5  3
  3:  a  3  4
  4:  c  6  5
  5:  c  2  2
  
  cnm&lt;-c("X2","X3")
  
  df[[cnm]]
  </code></pre>
  
  <blockquote>
    <p>Error in .subset2(x, i, exact = exact) : subscript out of bounds</p>
  </blockquote>
  
  <p>thanks</p>