I would like to get all unique elements in a dataframe and know how many times they occur over the matrix, think of something like this:
I'd want a matrix indicating "11" occurs 1 time etc.
sort(unique(c(matrix)))
is how far I got.
As this is more of a gimmick to a combinatorial problem, is a matrix the best solution to this anyway?
Thank you for any help for a beginner !
We can directly use table
to get the frequency of all the unique
elements in the matrix
table(matrix)