I currently have this data frame:
sex Dose weekReceived
1   M    1            1
2   F    2            2
3   M    3            2
4   M    1            3
5   M    1            2
6   F    2            1
7   M    1            1
and I would like this data frame:
weekReceived Dose M F
1            1    1 2 0
2            1    2 0 1
3            2    1 1 0
4            2    2 0 1
5            2    3 1 0
6            3    1 1 0
To explain the second data frame, what I am trying to do is calculate the number of males and females who have received each dose by week (e.g. for line 1 in the second data frame tells us that two males received dose 1 in week 1).
Which function do I use for this sort of reformat?