I have an R data table where one of the columns is effectively a factor, say, day of the week. How can I arrange a different column of the table into a matrix, and that matrix's columns correspond to each day of the week?
For example, the original table is
Mon 21 A
Tue 50 C
Thur 12 D
Wed 11 K
...
Mon 9 B
Wed 100 S
Tue 99 Z
Thur 32 J
where it is guaranteed each day of the week (in this sample only Mon - Thur) appear the same number of times. Now I want to arrange the 2nd column to a matrix of (with the column title in parenthesis, not part of the matrix)
(Mon Tue Wed Thur)
21 50 11 12
...
9 99 100 32
What is the best way to do that? Thx!