title: How to select columns in data.table using a character vector of certain column names?
body: <p>I am trying to select those columns in a data.table whose name appears in my character vector. The operation works in a pure data.frame, but doesn't work in a data.table. Here's a reproducible example. </p>
  
  <pre><code>&gt; names(mtcars)
   [1] "mpg"  "cyl"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear"
  [11] "carb"
  &gt; myVector &lt;- c('disp', 'hp', 'wt')
  &gt; head(mtcars[, myVector])
                    disp  hp    wt
  Mazda RX4          160 110 2.620
  Mazda RX4 Wag      160 110 2.875
  Datsun 710         108  93 2.320
  Hornet 4 Drive     258 110 3.215
  Hornet Sportabout  360 175 3.440
  Valiant            225 105 3.460
  </code></pre>
  
  <p>I just made a vector which includes <code>disp</code>, <code>hp</code>, and <code>wt</code> and I selected the corresponding columns in my data.frame using that vector. Let's now make a data.table object from my data.frame and try to do the same operation. </p>
  
  <pre><code>&gt; library(data.table)
  &gt; mtcarsDT &lt;- data.table(mtcars)
  &gt; mtcarsDT[, myVector]
  [1] "disp" "hp"   "wt"  
  </code></pre>