I have next DataFrame in R:
col1 col2 col3
a W 1
a Q 1
b T 2
b W 3
b Q 1
b Z 2
c T 3
c Z 1
....
I want to transform it in the next Data Frame
col1 T W Q Z
a 0 1 1 0
b 2 3 1 2
c 3 0 0 1
...
What is the most efficient way to do it in R?