Monthly Average Temperature in Cincinnati (2015-2019)

This weather data is extracted from University of Dayton, Average Daily Temperature Archive. The initial data includes month, day, year, and daily average temperature, calculated by (daily minimum + maximum temperature)/2, from January 1995 to May 2020.

library(magrittr) 
library(tidyverse) 
library(plotly)

# Import the data from URL
# Load package readr
library(readr)
url <- "http://academic.udayton.edu/kissock/http/Weather/gsod95-current/OHCINCIN.txt"
weather <- read_table(url, col_names = c("Month", "Day", "Year", "Temp"))
str(weather)
weather$Year  <- as.factor(weather$Year) 
weather$Temp[weather$Temp==-99]  <- NA

The daily data was aggregated by Month, and the monthly average has been plotted. As shown below, each color represents different year, and it seems there are no significant changes in temperature over the last five years. The average temperature in February 2015 was the lowest with 23.5F and highest in July 2019 with the average temperature of 77.8F.

monthly_temp <- weather %>% 
  filter(Year %in% c(2015:2019)) %>% 
  filter(!is.na(Temp)) %>% 
  group_by(Year, Month) %>% 
  summarize(avg_temp=mean(Temp))

p <- ggplot(data=monthly_temp, aes(x=Month, y=avg_temp, color=Year)) + 
  geom_line(size=1, alpha=1) + 
  scale_color_manual(values=c("#c6dbef", "#9ecae1", "#6baed6", "#3182bd", "#08519c")) + 
   theme(axis.text.x=element_text(angle=0, size=10, vjust=-1, hjust=0.5)) +
  ggtitle("Interactive Monthly Average Temperature in Cincinnati") +
  labs(x="", y="Temperature (F)", color="Year") +
   scale_x_continuous(breaks=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 
                      labels=c("Jan", "Feb", "Mar",  "Apr",  "May",  "Jun",                        "Jul",  "Aug",  "Sep",  "Oct",  "Nov" , "Dec")) 

ggplotly(p)