I have a fairly large dataset in R where column "date" has daily dates from the 1980s until 2017 and column "mean" has historical mean daily flow values. I want to be able to compare the flow from year to year so I want to transform my data set so that each column represents a year (from 1980 - 2017) and each row is a day of the year. Each observation is the mean daily flow for a given day of the year on a given year. The new dataset would therefore have 365 rows (366 if leap year?) and 38 columns; If accounting for leap years adds a level of complexity, I can do without it. I would appreciate any help on how I could do this. Thank you.
Asked
Active
Viewed 12 times
0
-
I've linked to the FAQ on changing data from long format to wide format. I'd highly recommend the answer that uses `tidyr::pivot_wider`, but there are plenty of other options too. If you need more help than that, please ask a new question including a little bit of sample data (4 dates from 2 or 3 years should be plenty to illustrate the problem), show what you tried, and we can help get you unstuck. – Gregor Thomas Oct 03 '22 at 14:38