I am trying to create a new table from an existing one.
I've selected the columns I need, Month, Year, and Temperature. There are is one row for each day.
I've managed to add another column, with a 1 or 0 for each day above freezing.
I would now like to aggregate the rows so I have a row for each season and a column for each year, as well as an annual total row.
KAN_U <- kan_u_df %>%
select(Year, MonthOfYear, AirTemperature.C.)
KAN_U$Melt <- as.numeric(KAN_U$AirTemperature.C. > 0)
head(KAN_U)
Year MonthOfYear AirTemperature.C. Melt
1 2009 4 -999.00 0
2 2009 4 -25.30 0
3 2009 4 -23.44 0
4 2009 4 -28.18 0
5 2009 4 -32.15 0
6 2009 4 -24.35 0'
I would like my final table to look as such
Total Winter Spring Summer Autumn
2009 10 0 2 7 1
2010 10 0 2 7 1
2011 10 0 2 7 1