Get counts of categorical factors across multiple variables/columns in R
<p>I have the following minimal example in R:</p>

<pre><code>testing = data.frame(c("Once a week", "Once a week", "Rarely", "Once a month", "Once a month"), c("Once a month", "Once a month", "Once a week", "Rarely", "Rarely"))
colnames(testing) = c("one", "two")
testing

        one          two
1  Once a week Once a month
2  Once a week Once a month
3       Rarely  Once a week
4 Once a month       Rarely
5 Once a month       Rarely
</code></pre>

<p>I want the end result to be a dataframe that has all the possible categorical factors in one column and the rest of the columns are the counts for each column/variable like this:</p>

<pre><code>categories    one    two
Rarely        1      2
Once a month  2      2
Once a week   2      1
</code></pre>

<p>I have no restrictions on R libraries so whatever would be the easiest here (maybe <code>plyr</code>/<code>dplyr</code>?).</p>

<p>Thanks.</p>