I have a dataset as shown below
time customerID Material
20170101 1 a
20170101 1 b
20170102 1 d
20170102 1 e
20170102 1 f
20170101 2 s
20170102 2 a
20170102 2 c
And I want to convert something like:
time customerID Material.1 Material.2 Material.2
20170101 1 a b
20170102 1 d e f
20170101 2 s
20170102 2 a c
To create a Sample table, run it in R:
time <- c(20170101, 20170101, 20170102, 20170102, 20170102, 20170101, 20170102, 20170102)
customerID <- c(1,1,1,1,1,2,2,2)
Material <- c('a','b','d','e','f','s','a','c')
df <- data.frame(time, customerID, Material)
I tried Reshape, but it did not work as I expected. Any pointers to this would be much appreciated.
source
share