Consider the following matrix:
M <- cbind(c("ID001", "ID003", "ID002", "ID002", "ID003"),
c("BK101", "BK145", "BK101", "BK125", "BK101"),
c(6, 3, 2, 7, 3))
I want to reshape the matrix, so I get the following matrix:
BK101 BK125 BK145
ID001 6 0 0
ID002 2 7 0
ID003 3 0 3
I have tried with:
reshape(M, idvar=[,1], timevar=[,2])
But that does not work.