This may be a beginner question but I can't find an answer on the webs... maybe because I'm not good at describing the problem.
I want to create a frequency table of nominal data separate by rows. For example, in this matrix:
x <- matrix(nrow = 3, ncol = 3,
c("A","B","B",
"C","C","B",
"D","A","B"
))
Using the table(x) function gives me:
A B C D
2 4 2 1
But I want to obtain separate counts for each row, where the resulting table is:
A B C D
1 2 0 00 1 1 0
1 1 0 1
I'm sure this is some version of a contingency table but for the life of me, I can't figure it out.