title: converting two column data table to data table with colnames from one column and values from the other
body: <p>Any more elegant way to do <code>tdt</code> as shown in the following example using base or data.table functions and operations only?</p>
  
  <pre><code>library(data.table)
  dt &lt;- data.table(a = letters[1:5], b = 1:5)
  dt
  # a b
  # 1: a 1
  # 2: b 2
  # 3: c 3
  # 4: d 4
  # 5: e 5
  tdt &lt;- data.table(t(matrix(dt$b, dimnames = list(dt$a, NULL))))
  tdt
  # a b c d e
  # 1: 1 2 3 4 5
  </code></pre>