Cold Oktober

Am I cold or am I imagining it?

Robert Myles McDonnell

2 minute read

Moving back to Ireland from Brazil has me feeling cold. This got me thinking that seems like an unusually cold October, but, since I just moved here, I may not be a reliable guide. I was wondering whether I was a) correct, or b) a weakling, unable to withstand temperatures I would have previously considered normal. Well, I did what every data scientist would do in such a situation – I found data, cleaned it up and made graphs. I was able to scrape some recent data from met eireann’s historical site and download historical data from the World Bank’s Climate Change Knowledge Portal, both of which needed some cleanup:

library(tidyverse); library(glue);library(rvest)
library(readxl); library(lubridate);
library(r2d3)

source("https://raw.githubusercontent.com/RobertMyles/r_utils/master/char_from_copy.R")
source("https://raw.githubusercontent.com/RobertMyles/r_utils/master/month_changer.R")


tabl <- read_html('http://archive.met.ie/climate/monthly-data.asp?Num=518') %>% 
  xml_nodes('#climate-report > table:nth-child(5)') %>% 
  html_table() %>% .[[1]] %>% 
  magrittr::set_colnames(
    value = char_from_copy(
      "Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Annual"
      )) %>% 
  slice(-1) %>% 
  mutate_all(as.numeric) %>% 
  slice(-5) %>% select(-Annual) %>% 
  gather("Month", "temp", -Year) %>% 
  month_changer("Month") %>% 
  mutate(Day = "01",
         date = glue('{Year}-{Month}-{Day}')) %>% 
  select(-c(Year, Month, Day)) %>% 
  filter(year(parse_date_time(date, 'ymd')) > 2015)


temps <- read_excel('~/Downloads/tas_1901_2015.xls') %>% 
  rename("temp" = "tas") %>% 
  mutate(Day = "01",
         date = glue('{Year}-{Month}-{Day}')) %>% 
  select(-c(Country, Year, Month, Day, ISO3, ISO2)) %>% 
  bind_rows(tabl) %>% 
  filter(!is.na(temp)) %>% 
  arrange(parse_date_time(date, 'ymd'))

Combining these gives us this table:

knitr::kable(head(temps))
temp date
4.63153 1901-1-01
3.04590 1901-2-01
4.33499 1901-3-01
7.53272 1901-4-01
10.96600 1901-5-01
12.39040 1901-6-01
knitr::kable(tail(temps))
temp date
17.4 2018-07-01
15.5 2018-08-01
12.8 2018-09-01
10.4 2018-10-01
8.3 2018-11-01
8.2 2018-12-01
comments powered by Disqus