I have a data frame that I need to export to excel
In the excel I need the columns to be the years, the first row the code and the monthly rainfall values to be for each year and code. The excel should have a sheet for each month, For example, the sheet for the month of April should be similar to this
`código 2000 2001 2002 .... 2019
87345 116.3
87347 103.6
....
87467
`
First convert the years to Wide format with the function pivot_wider
Then separate the df in a list with the monthly df with the split function
The function write.xlsx understands that each element of the list is a tab