title: Retrieving dynamic sets of columns from a data.table
body: <p>Assigning sets of columns whose names are stored in a character vector is well discussed, but I can't seem to find a solution to retrieve columns and operate on them.</p>
  
  <pre><code>cols = c("x", "y")
  DT = data.table(x = 10:15, y = 20:25)
  
  &gt; DT
      x  y
  1: 10 20
  2: 11 21
  3: 12 22
  4: 13 23
  5: 14 24
  6: 15 25
  </code></pre>
  
  <p><strong>Desired Output</strong></p>
  
  <pre><code>&gt; DT[,paste(x,y)]
  
  [1] "10 20" "11 21" "12 22" "13 23" "14 24" "15 25"
  </code></pre>
  
  <p>My goal is to get a unique identifier for each row based on the columns in <code>cols</code>. I can do this by hard coding the column names but I'd rather reference <code>cols</code></p>
  
  <hr>
  
  <p>Here are some syntax I have tried and their output.</p>
  
  <p><strong>get()</strong></p>
  
  <pre><code>&gt; DT[,get(cols)]
  
  [1] 10 11 12 13 14 15
  </code></pre>
  
  <p><strong>Parentheses</strong></p>
  
  <pre><code>&gt; DT[,(cols)]
  
  [1] "x" "y"
  </code></pre>
  
  <p><strong>List</strong></p>
  
  <pre><code>&gt; DT[,as.list(cols)]
     V1 V2
  1:  x  y
  </code></pre>
  
  <p><strong>with=F</strong></p>
  
  <pre><code>&gt; DT[,cols, with=F]
  
      x  y
  1: 10 20
  2: 11 21
  3: 12 22
  4: 13 23
  5: 14 24
  6: 15 25
  </code></pre>
  
  <p>This works but I am unable to operate on the columns:</p>
  
  <pre><code>&gt; DT[,paste(cols), with=F]
  
      x  y
  1: 10 20
  2: 11 21
  3: 12 22
  4: 13 23
  5: 14 24
  6: 15 25
  </code></pre>