How to create a denormalized dataframe with the value and type coming from a set of other variables in R : <p>So I have the following dataframe:</p>

<pre><code>&gt; data.frame(id=c(1,2),a=c(10,11),b=c(20,21))  
id  a  b
1 10 20
2 11 21
</code></pre>

<p>I want to create a denormalized dataframe that takes the values of two or more columns and creates two columns, one for the column that the value comes from, and other with the value itself, so the final dataframe has more rows than columns.</p>

<p>The result should look like this:</p>

<pre><code>&gt; data.frame(id=c(1,1,2,2),x=c(10,20,11,21),type=c("a","b","a","b"))
    id  x type
    1 10    a
    1 20    b
    2 11    a
    2 21    b
</code></pre>

<p>Where the order of the values does not matter, of course.</p>

<p>Thanks everyone!</p>
