What is a good way to get the independent frequency counts of multiple columns using dplyr? I want to go from a table of values:
dplyr
# A tibble: 7
For the same data set that you provided in the question this would be another solution (base-R):
myfreq <- sapply(df, function(x) table(factor(x, levels=unique(unlist(df)), ordered=TRUE)))
Output would be:
> myfreq # a b c d # 1 2 0 2 1 # 2 1 4 2 0 # 3 2 2 0 6 # 5 2 0 1 0 # 4 0 1 2 0