I would like to reshape a data frame.
Data:
a <- c("A_h:old","A_h:new","A_h:old","A_h:new","A_h:old","A_h:new","A_h:old","A_h:new")
b <- c("2015-08-11","2015-08-11","2015-08-12","2015-08-12","2015-08-13","2015-08-13","2015-08-14","2015-08-14")
c <- c(12,10,12,23,16,17,7,9)
df <- data.frame(a,b,c)
Which produces:
a b c
A_h:old 2015-08-11 12
B_h:new 2015-08-11 10
A_h:old 2015-08-12 12
B_h:new 2015-08-12 23
A_h:old 2015-08-13 16
B_h:new 2015-08-13 17
A_h:old 2015-08-14 7
B_h:new 2015-08-14 9
Desired outcome:
b A_h:old B_h:new
2015-08-11 12 10
2015-08-12 12 23
2015-08-13 16 17
2015-08-14 7 9
I tried to use:
reshape(df, timevar = "b", idvar = c(" A_h:old", "B_h:new"), direction = "wide")
unsuccessfully.