I would like to reshape my data frame from long to wide by 2 variables (whose combinations create new unique identifier) while aggregating values by product, product2, and date so that the following:
Date product product2 value
03/03/2011 a z 7
03/03/2011 a z 2
03/05/2015 b z 89
03/01/2017 a z 2
03/03/2017 c z 6
which would yield the following:
03/03/2011 03/03/2011 03/05/2015 03/01/2017 03/03/2017
a z 9 2
b z 89
c z 6
Should I use dplyr, reshape, reshape2?
df <- structure(list(Date = c("03/03/2011", "03/03/2011", "03/05/2015", "03/01/2017", "03/03/2017"),
product= c("a", "a", "b", "a", "c"),
product2= c("z", "z", "z", "z", "z"),
value= c(7L, 2L, 89L, 2L, 6L)),
.Names= c("Date", "product", "product2", "value"),
class= "data.frame", row.names=c(NA, -5L))