Taking the frequency of three different columns : <p>I have a dataframe like this:</p>

<pre><code>df &lt;- structure(list(col1 = structure(c(1L, 1L, 2L, 3L, 1L, 3L, 1L, 
3L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 4L), .Label = c("stock1", 
"stock2", "stock3", "stock4"), class = "factor"), col2 = structure(c(4L, 
5L, 7L, 6L, 5L, 5L, 5L, 6L, 6L, 8L, 8L, 4L, 3L, 3L, 1L, 2L, 3L
), .Label = c("comapny1", "comapny1+comapny4", "comapny4", "company1", 
"company2", "company2+company1", "company3", "company4"), class = "factor"), 
    col3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("predictor1", "predictor2"
    ), class = "factor")), .Names = c("col1", "col2", "col3"), class = "data.frame", row.names = c(NA, 
-17L))
</code></pre>

<p>I would like to take the frequency from the three columns.</p>

<p>Expected output</p>

<pre><code>df2 &lt;- structure(list(col1 = structure(c(1L, 1L, 1L, 2L, 4L, 1L, 1L, 
3L, 3L, 1L, 2L, 1L), .Label = c("stock1", "stock2", "stock3", 
"stock4"), class = "factor"), col2 = structure(c(1L, 2L, 3L, 
3L, 3L, 4L, 5L, 5L, 6L, 6L, 7L, 8L), .Label = c("comapany1", 
"comapany1+comapany4", "comapany4", "company1", "company2", "company2+company1", 
"company3", "company4"), class = "factor"), col3 = structure(c(2L, 
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("predictor1", 
"predictor2"), class = "factor"), frequency = c(1L, 1L, 1L, 1L, 
1L, 2L, 3L, 1L, 2L, 1L, 1L, 2L)), .Names = c("col1", "col2", 
"col3", "frequency"), class = "data.frame", row.names = c(NA, 
-12L))
</code></pre>

<p>How is it possible to make it?</p>
