library(tidyverse)
library(data.table)
library(scales)

First I loaded the the following packages needed for my graph:

weather <- fread("C:/Users/Metz/Desktop/1Spring Semester 2022/Data Wrangling BANA 7025/Week 5/weatherHistory.csv")

Now reading in the Weather Dataset that I aquired from Kaggle.com with fread, a faster reading function from the package data.table.

#Get Month and Day
weather %>% 
  mutate(date = format(as.POSIXct(`Formatted Date`,format='%Y/%m/%d %H:%M:%S'),format='%m/%d')) -> weather_update
#Get Year
weather_update %>% 
  mutate(year = format(as.POSIXct(`Formatted Date`,format='%Y/%m/%d %H:%M:%S'),format='%Y')) -> weather_update
#Filter Data from 2015
weather_update %>% 
  filter(year==2015) %>% 
    group_by(date) %>% 
      summarise(`Min Temp in 2015`=min(`Temperature (C)`), `Max Temp in 2015`=max(`Temperature (C)`)) -> min_max_temp_2015
#Filter Data previous of 2015
weather_update %>% filter(year<2015) %>% 
  group_by(date) %>% 
    summarise(`Min Temp previous years combined`=min(`Temperature (C)`), `Max Temp previous years combined`=max(`Temperature (C)`)) -> min_max_temp
#Join the two data sets
min_max_temp <- min_max_temp %>% 
  inner_join(min_max_temp_2015, by = "date")
#Change date type
min_max_temp$date <- as.POSIXct(min_max_temp$date, format='%m/%d')
#Pivot Longer
min_max_temp <- min_max_temp %>% 
  pivot_longer(2:5,names_to="MIN_MAX",values_to="TEMP")
#Create Graph
ggplot(min_max_temp, aes(x= date, y= TEMP, color= MIN_MAX)) + 
    scale_x_datetime(labels = date_format("%b")) +
    geom_line()+ scale_color_manual(values=c("darkred", "red", "darkblue" , "skyblue")) +
    labs(title = "Temperature from 2015 with high and low boarders recorded 10 years back", subtitle = "Year 2015", x = "Months", y = "Temperature in °C") +
    geom_hline(yintercept=0, linetype="dashed", color = "black") +
    guides(color = guide_legend('Temperature Chart'))

This graph shows that over the last 10 years there were still outliers more so in the max temperature area which indicates that weather is continuously changing.