I have the following data:
id brand quantity
1 a 2
1 b 1
2 b 5
3 c 10
2 d 11
3 a 1
4 b 2
The output should be
a b c d
1 2 1 0 0
2 0 5 10 11
3 1 0 10 0
4 0 2 0 0
How to get this type of sort in R language where the column names are brand types and row names are customer ids and the matrix data are quantity?