My original data frame is this:
x
Team Date variable value
A 2012-07-01 Score 13
A 2012-07-02 Score 12
A 2012-07-03 Score 2097
A 2012-07-04 Score 45
A 2012-07-05 Score 41
A 2012-07-06 Score 763
need to to be like this
z
Team 2012-07-01 2012-07-02 2012-07-03 2012-07-04 2012-07-05 2012-07-06
A 13 12 2097 45 41 763
library(reshape)
z<-cast(x, Team + variable ~ Date)
I get a warning message stating this:
Aggregation requires fun.aggregate: length used as default
Use
dcastfrom reshape2 package and it’ll work!Edit:
You can use
reshapefunction from stats. No additional package is required as above.