Create an Rpubs blog showing how to create a monthplot of the mean rainfall data for Ireland on a month-by-month basis from January 1970 to December 1979, and briefly describe the patterns in the plot.
Firstly the directory must be set and libraries loaded: setwd(“D:\CC\R\CB’s Lecture Resources”) This will be different for different machines and filing pathways.
## Warning: package 'dplyr' was built under R version 3.4.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Warning: package 'ggvis' was built under R version 3.4.3
## Warning: package 'dygraphs' was built under R version 3.4.3
## Warning: package 'reshape2' was built under R version 3.4.3
## # A tibble: 6 x 2
## Station mrain
## <chr> <dbl>
## 1 Ardara 140
## 2 Armagh 68.3
## 3 Athboy 74.7
## 4 Belfast 87.1
## 5 Birr 70.8
## 6 Cappoquinn 121
## # A tibble: 6 x 2
## Month mrain
## <fctr> <dbl>
## 1 Jan 113
## 2 Feb 83.2
## 3 Mar 79.5
## 4 Apr 68.7
## 5 May 71.3
## 6 Jun 72.7
Each of the above commands have created a data frame, one for the mean rainfall for the stations called rain_summary and another for mean monthly rainfall called rain_months. It is also possible to combine mean rainfall with month/station combination using multiple groupings
head(rain_season_station)
## # A tibble: 6 x 3
## # Groups: Month [1]
## Month Station mean_rain
## <fctr> <chr> <dbl>
## 1 Jan Ardara 175
## 2 Jan Armagh 74.6
## 3 Jan Athboy 84.9
## 4 Jan Belfast 101
## 5 Jan Birr 79.9
## 6 Jan Cappoquinn 154
Use acast for a vector/matrix/ array output, dcast is for data frame output (you can have at most two dimensions in a data frame output)
## Using mean_rain as value column: use value.var to override.
## Jan Feb Mar Apr May Jun
## Ardara 174.82606 126.82303 123.02000 98.79333 96.90727 105.24061
## Armagh 74.57242 55.97182 56.48879 53.67030 59.23182 62.72939
## Athboy 84.94759 62.62133 62.44944 58.97874 62.16260 68.11460
## Belfast 101.20718 74.50206 73.10221 65.90492 69.23426 74.48525
## Birr 79.92074 57.88501 58.42056 54.07187 60.25831 61.96445
## Cappoquinn 153.97159 117.77099 110.02890 94.00365 95.81437 94.86357
## Cork Airport 138.28667 102.63030 92.33394 76.74061 77.24545 71.45879
## Derry 100.00639 74.58726 70.17965 62.89350 63.98542 72.86780
## Drumsna 97.15529 74.44790 71.92887 63.57159 68.86541 72.98245
## Dublin Airport 63.70121 48.96788 51.32485 49.24667 56.12909 56.29273
## Enniscorthy 127.87980 93.68550 89.41246 76.98902 78.46741 75.13353
## Foulksmills 107.75818 77.93758 73.71333 65.76303 66.19939 69.54970
## Killarney 181.08232 127.49602 114.49780 92.04441 86.40749 82.28648
## Malin Head 105.77455 77.99333 72.84970 61.06424 59.90485 71.29455
## Markree Castle 115.03758 83.90848 83.25455 69.02727 73.62303 80.69758
## Jul Aug Sep Oct Nov Dec
## Ardara 123.70485 145.24788 152.80727 174.44788 176.45030 186.14182
## Armagh 72.50636 81.92182 69.02576 80.94242 73.73121 79.05939
## Athboy 76.28662 88.84710 76.35077 88.14627 80.95767 87.05997
## Belfast 87.70003 102.44499 87.11622 106.35394 100.31760 102.95073
## Birr 75.10084 86.75669 72.21722 83.80810 77.87266 81.74334
## Cappoquinn 104.09372 125.42245 116.04466 146.70658 141.10012 154.87402
## Cork Airport 76.87818 92.78606 91.70000 120.36545 121.18424 138.39030
## Derry 83.43445 94.12148 85.30597 102.56368 100.34137 104.17246
## Drumsna 82.13707 96.95270 83.07678 97.36597 95.30862 102.37824
## Dublin Airport 64.08121 74.94061 61.75697 73.83394 68.63091 68.27939
## Enniscorthy 85.27952 100.96359 93.44526 119.63919 115.55605 126.63838
## Foulksmills 75.52788 87.62909 82.97030 109.65212 102.83758 108.75697
## Killarney 89.86281 110.38373 114.28296 154.94155 162.31584 180.52044
## Malin Head 85.47152 97.42667 95.19333 108.43515 109.61212 108.63697
## Markree Castle 91.21091 106.90424 97.97091 115.64364 113.82424 120.36848
To produce a monthplot, you must first produce a timeseries:
rain_ts %>% window(c(1870,1), c(1879,12))
## Jan Feb Mar Apr May Jun Jul Aug
## 1870 113.452 86.356 38.564 138.288 59.684 54.496 103.392 76.256
## 1871 195.020 55.196 79.916 54.724 44.968 101.484 90.332 96.648
## 1872 161.444 92.448 44.640 44.400 70.184 179.396 68.640 110.080
## 1873 144.744 42.956 83.520 75.276 33.164 77.468 100.492 82.880
## 1874 138.568 36.036 37.336 18.760 99.964 110.352 102.608 60.480
## 1875 16.500 59.096 86.032 36.664 79.780 68.224 84.088 104.952
## 1876 111.648 81.984 35.896 76.220 124.076 59.612 44.720 87.664
## 1877 97.232 56.728 98.324 118.712 53.756 81.720 59.420 66.352
## 1878 61.420 69.712 51.708 143.532 86.412 43.040 82.972 69.508
## 1879 89.812 50.964 90.132 106.932 16.284 36.452 63.100 90.332
## Sep Oct Nov Dec
## 1870 70.524 62.712 113.140 104.004
## 1871 49.380 113.368 45.372 68.768
## 1872 57.324 88.708 223.248 208.236
## 1873 60.164 185.104 106.044 48.372
## 1874 47.816 77.800 74.640 94.932
## 1875 50.712 103.244 49.200 87.416
## 1876 91.708 82.412 39.316 115.328
## 1877 90.608 80.428 95.684 64.416
## 1878 85.300 83.200 68.632 141.108
## 1879 132.420 76.908 119.984 115.892
rain_ts %>% window(c(1870,1), c(1879,12)) %>%
monthplot(col='dodgerblue', col.base = 'indianred', lwd.base = 3)
title('Monthplot of average Irish Rainfall 1870-1879')
Examining the monthplot for the decade of the 1870s, the months with higher levels of precipitation are easily recognised. The months January, October, November and December all have high spikes of average rainfall. Surprisingly, July and to a lesser extent, April also spike for high precipitative events. January, April and May have the lowest levels of average rainfall. This occurs in mid-decade for January and April, while May’s dry spell appears to occur twice, once close to mid-decade, possibly 1873/4, and again at the end of the decade.