0

I have a data frame as follows:

 A1     A2     A3           
  1      2      3     
  1      2      3     

I would like to convert the dataframe above into something like this:

 M1    M1    M1  ..... M1     M2    M2  ...... M3     M3     M3  ...... M3
  1     1     1  .....  1      2     2  ......  2      3      3  ......  3
  1     1     1  .....  1      2     2  ......  2      3      3  ......  3 

where M1, M2 and M3 are repeated 12 times (for each month)

I have tried the duplicate function. It worked if I only attempted to duplicate one column. However, everything went haywire if I tried more than 2 columns.

Thanks

southwind
  • 636
  • 4
  • 15
  • Possible duplicate of [How to convert annual data to monthly data using R?](https://stackoverflow.com/questions/31902632/how-to-convert-annual-data-to-monthly-data-using-r) – duckmayr Nov 19 '17 at 12:20
  • Like this? `xy <- data.frame(A1 = 1, A2 = 2, A3 = 3); xy[, rep(1:3, each = 12)]`. – Roman Luštrik Nov 19 '17 at 12:38

0 Answers0