0

I have a table that in principle looks like this (the actual one has many more observations):

enter image description here

And I would like that the end result looks like this:

enter image description here

I am not sure how to even start with constructing the table so that it has a doubleheader....

Mark
  • 7,785
  • 2
  • 14
  • 34
  • 1
    In what medium are you hoping to output this table? Are you doing Rmarkdown to HTML or Word or PDF? Or something else? – Gregor Thomas Jun 14 '23 at 15:25
  • for now I would like to manipulate it as a dataframe. Then I am thinking to create three tables (one for each topX) with gt with the percentage changes from one period to another – Ayoze Alfageme Jun 14 '23 at 15:28
  • 1
    Data frames don't have multiple headers, so I'd suggest rethinking that. – Gregor Thomas Jun 14 '23 at 15:30
  • ok, thanks for the clarification! – Ayoze Alfageme Jun 14 '23 at 15:55
  • 1
    You could `pivot_wider` the table to encode both sets of information in a single header, with column names like `top4_1999`, `top10_1999`, etc. If you're interested in that, check out the [reshape from long to wide FAQ](https://stackoverflow.com/q/5890584/903061). There's many methods, I'd recommend the `pivot_wider` approach. – Gregor Thomas Jun 14 '23 at 15:58

0 Answers0