I have a data set that looks something like this:
id score
a 1
a 5
a 5
b 8
b 3
b 2
b 9
b 3
b 5
c 3
c 1
d 8
d 3
d 9
I'm looking to reshape the data so that I get a count of each number per variable, something like this:
1 2 3 4 5 6 7 8 9
a 1 0 0 0 2 0 0 0 0
b 0 1 2 0 1 0 0 0 1
c 1 0 1 0 0 0 0 0 0
d 0 0 1 0 0 0 0 1 1
I know that ddply can do this using the count(score==1), count(score ==2) function etc., but my actual data set has values from 1-100 and its inefficient to hardcore in 100 different functions for ddply.
Does anyone have a simple way to do this?