Hi I have been trying to transpose the data which have the structure like below;
ID Seq PRODUCT
A1 1 A
A1 2 B
A1 3 C
A1 4 D
A1 5 E
A2 1 C
A2 2 D
A2 3 E
A2 4 F
A3 1 A
A3 2 C
A3 3 D
and I need the new structure like this
ID 1 2 3 4 5
A1 A B C D E
A2 C D E F
A3 A C D
I have tried this code, but the output is still incorrect.
dt <- reshape(mydata, v.names = "Seq" ,timevar = "Seq", direction = "wide", idvar = "ID")
Recently I have tested
reshape(mydata, ,timevar = "Seq", direction = "wide", idvar = "ID")
but it seemed like my actual data have long "Seq", so the data is grouped in to a single column like below. How to expand the column? My actual data have maximum sequence around 30 sequences.
ID PROD 1:5
A1 NA
A2 NA
A3 NA