library(emphatic)
sydney_rain |> head(15)
#> Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
#> 1 1960 81.6 85.8 50.4 34.7 123.3 96.1 135.7 48.2 58.5 289.7 68.9 269.8
#> 2 1961 50.9 83.7 56.4 107.4 33.0 47.8 45.6 240.6 58.0 63.1 518.8 149.1
#> 3 1962 115.4 134.5 64.2 57.0 309.0 3.3 67.5 132.8 82.8 21.5 13.2 132.8
#> 4 1963 120.1 84.7 389.7 284.1 252.1 250.3 82.8 272.7 23.2 67.2 35.6 226.5
#> 5 1964 17.6 31.1 180.7 NA NA NA NA NA NA NA 24.2 20.1
#> 6 1965 27.5 11.4 8.2 92.5 55.9 229.0 83.3 18.9 106.8 199.2 43.7 64.7
#> 7 1966 26.6 145.6 140.1 265.9 77.3 143.1 17.6 82.1 65.4 56.6 191.2 92.4
#> 8 1967 179.9 155.5 127.3 47.2 52.8 271.3 26.8 198.4 105.3 84.4 88.0 53.9
#> 9 1968 131.9 13.0 125.8 13.3 108.2 30.4 69.9 38.7 1.6 6.0 19.0 88.9
#> 10 1969 42.7 230.9 108.3 151.6 59.9 215.8 50.8 39.7 81.9 48.0 274.6 36.4
#> 11 1970 153.1 58.6 NA 51.0 10.2 33.9 3.6 40.6 152.3 21.9 121.7 263.9
#> 12 1971 161.8 167.1 66.3 65.8 107.2 62.8 25.9 122.6 70.9 2.3 77.5 133.1
#> 13 1972 347.8 99.9 164.1 82.5 93.8 130.5 6.1 33.0 13.4 157.2 65.8 24.6
#> 14 1973 237.8 301.5 96.8 91.7 28.5 92.1 116.5 92.3 78.1 155.5 119.5 33.2
#> 15 1974 230.8 109.1 320.8 170.8 230.8 192.4 11.0 198.6 60.2 70.2 40.4 NA
Average monthly rainfall during the period 1960 - 2023
(mean_rain <- mean(unlist(sydney_rain[,-1]), na.rm = TRUE))
#> [1] 103.3679
Floods in NSW
Years in which flooding occurred in New South Wales according to wikipedia
flood_years <- c(1970, 1971, 1984, 1986, 1990, 1996, 1998, 2007, 2012, 2013, 2015, 2016, 2020, 2021, 2022)
Highlight months with above average rainfall and mark years in which
flooding occurred
sydney_rain |>
hl(
ggplot2::scale_colour_gradient2(na.value = 'white', low = 'white',
high = 'darkgreen', midpoint = mean_rain),
cols = Jan:Dec
) |>
hl('skyblue', rows = Year %in% flood_years, cols = 'Year') |>
hl_adjust(na = '') |>
as_svg(height = 1300)