-1

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:

example

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 !

bountan
  • 87
  • 7

1 Answers1

1

We can directly use table to get the frequency of all the unique elements in the matrix

table(matrix)
akrun
  • 789,025
  • 32
  • 460
  • 575