I have a data frame as below
Users Products
101 Potassium Monosulfame
102 Kathon
103 Tenox
102 Potassium Monosulfame
101 Tenox
101 Potassium Monosulfame
103 Kathon
101 Potassium Monosulfame
103 Kathon
I want to convert this data to a matrix having Users as rows and each unique products as columns and the values as frequencies. The desired output is given below
Users Potassium Monosulfame Kathon Tenox
101 3 0 1
102 1 1 0
103 0 2 1
Kindly guide me how to get this output in R.