With the plyr
package, use the count()
function (via).
This code computes the frequencies for each value that var
can take:
count(df, var)
If you want to have the frequencies of the combination of all the values of two variables, use this:
count(df, var1, var2)
If R does not display all the rows, use this:
as.data.frame(count(df, var1, var2)