The aim of this assignment was to create and analyze a dygraph in Rstudio of four weather stations, situated at Belfast, Dublin Airport, University College Galway and Cork airport using the “Rainfall.RData”. This data is presenting rainfall month by month from different stations since 1850 to 2014 Packages were needed in order to create the dygraph and were thus upload. For example “dplyr” is used to manipulate data, like filtering as shown later in the code or “RColorBrewer” is used for colors. The command “load” was then used to select in the computer the data file needed : “Rainfall.RData”.
library(dplyr)
Warning: package 'dplyr' was built under R version 4.3.2
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
library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.3.2
Warning: package 'ggplot2' was built under R version 4.3.2
Warning: package 'tibble' was built under R version 4.3.2
Warning: package 'tidyr' was built under R version 4.3.2
Warning: package 'readr' was built under R version 4.3.2
Warning: package 'purrr' was built under R version 4.3.2
Warning: package 'stringr' was built under R version 4.3.2
Warning: package 'forcats' was built under R version 4.3.2
Warning: package 'lubridate' was built under R version 4.3.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sp)
Warning: package 'sp' was built under R version 4.3.2
library(RColorBrewer)library(dygraphs)
Warning: package 'dygraphs' was built under R version 4.3.2
load("D:/GY672/rainfall.RData")
Next begin the coding of the dygraph in itself. After organizing the data file by years and months, each of the four station was individually selected with its own rainfall data throughout the time and renamed with its three first letter followed by a “ts” (for time series). After that, the four time series were combined under beldubunicor_ts and put into a dygraph with a range selector.
Once built, the dygraph was showing quite similar rainfall pattern in term of time for the four stations but with generally more quantity at Cork airport and University College Galway. Globally, the four stations had recorded sudden annually increases in rainfall during autumn to mid winter, in addition, rainfalls hadn’t shown any dramatic pattern changes since 1850.