Transforming daily data in wide format to long


Can you please take couple of rows in your dataset and convert them into reprex?

Second, take a look at readxl package. Since you have composite headers (each month is one header and then each variable is another), you first need to read it in properly so that it will make it easier to work with.

Once this is done, converting your initial table to the format you want is straightforward. It'll be a combination of gather, separate and spread from tidyr package.

Very similar example from that package with solution is available as a demo here -

1 Like