0

I have a data frame that looks something like this

A B    C
x 2013 23
x 2014 47
x 2015 83

I'd like to transform it so that I have all data and other dimensions for x in one row:

A B    C  D    E   F    G
x 2013 23 2014 47  2015 83

How can I do this using R? Can I use the Reshape package?

Many thanks,

Jim

JimS
  • 1,123
  • 3
  • 14
  • 17
  • Add a time variable based on "A" and reshape wide... – A5C1D2H2I1M1N2O1R2T1 Feb 05 '16 at 17:02
  • Or another [recent Q&A](http://stackoverflow.com/questions/35207472/rearrange-dataframe-by-subsetting-and-column-bind) – Jaap Feb 05 '16 at 17:05
  • @Jaap I asked how this would be done using the Reshape package. Neither of the duplicate questions show that. – JimS Feb 22 '16 at 08:45
  • @Jim yes it does, based on the answer in the duplicate link: `dcast(setDT(mydf), A ~ rowid(A), value.var=c('B', 'C'))` after that you can rearrange and rename the columns – Jaap Feb 23 '16 at 09:09

0 Answers0