Transpose a data.table (columns names -> first column of output)
<p>What is the most efficient way to traspose </p>

<pre><code>&gt; dt &lt;- data.table( x = c(1, 1, 3, 1, 3, 1, 1), y = c(1, 2, 1, 2, 2, 1, 1) )
&gt; dt
   x y
1: 1 1
2: 1 2
3: 3 1
4: 1 2
5: 3 2
6: 1 1
7: 1 1
</code></pre>

<p>into:</p>

<pre><code>&gt; output
    cn   v1   v2   v3   v4   v5   v6   v7
1:   x    1    1    3    1    3    1    1
2:   y    1    2    1    2    2    1    1
</code></pre>

<p>dcast.data.table is supposed to be efficient, but I can't figure out how exactly it has to be done</p>