KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
For a matrix (as.matrix), how can I generate a table where rows are equal to rows of the matrix? >table(matrix) and >hist(matrix) show the cumulative sum for each unique data value in the matrix, but I would like a table where rows are the same value as each matrix row, and table columns are the sum occurrence of each unique data value in the matrix. Example matrix: 1 2 3 4 a 5 5 4 6 b 5 5 5 5 c 8 7 6 6 d 2 6 6 6 e 7 7 5 4 Desired output table: 2 4 5 6 7 8 a 0 1 2 1 0 0 b 0 0 4 0 0 0 c 0 0 0 2 1 1 d 1 0 0 3 0 0 e 0 1 1 0 2 0
Tags (comma-separated)
Save Edits
Cancel