Olympia Weather Factoids

Harold Nelson

2/28/2024

Setup

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.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(lubridate)
load("OAW2309.Rdata")

Above 100

On what days has the maximum daily temperature exceeded 100 degrees? How many? When?

Solution

OAW2309 %>% 
  filter(TMAX > 100) %>% 
  arrange(TMAX) %>% 
  select(DATE,TMAX) 
## # A tibble: 13 × 2
##    DATE        TMAX
##    <date>     <dbl>
##  1 1942-06-30   101
##  2 2006-07-21   101
##  3 2009-07-28   101
##  4 1942-07-01   102
##  5 1981-08-10   102
##  6 1994-07-20   102
##  7 2021-06-26   102
##  8 1941-07-15   103
##  9 1941-07-16   103
## 10 1981-08-09   104
## 11 2009-07-29   104
## 12 2021-06-27   105
## 13 2021-06-28   110

Below Zero

Repeat the exercise above for days with a TMIN below zero.

Solution

OAW2309 %>% 
  filter(TMIN < 0) %>% 
  arrange(TMIN) %>% 
  select(DATE,TMIN)
## # A tibble: 12 × 2
##    DATE        TMIN
##    <date>     <dbl>
##  1 1979-01-01    -8
##  2 1972-01-27    -7
##  3 1983-12-23    -7
##  4 1978-12-31    -5
##  5 1972-01-28    -4
##  6 1972-12-08    -3
##  7 1983-12-22    -3
##  8 1950-02-01    -1
##  9 1955-11-15    -1
## 10 1972-02-02    -1
## 11 1972-12-10    -1
## 12 1998-12-22    -1

Heavy Rain

What were the ten heaviest days of rainfall in Olympia. Sort them by date.

Solution

OAW2309 %>% 
  arrange(PRCP) %>% 
  tail(10) %>% 
  arrange(desc(PRCP)) %>% 
  select(DATE, PRCP)
## # A tibble: 10 × 2
##    DATE        PRCP
##    <date>     <dbl>
##  1 2009-01-07  4.82
##  2 1962-11-19  4.33
##  3 2006-11-06  4.31
##  4 2003-10-20  4.12
##  5 1990-11-24  4.08
##  6 2022-01-06  3.99
##  7 1990-01-09  3.82
##  8 1951-02-09  3.64
##  9 2001-11-14  3.64
## 10 1956-12-09  3.5

Bad Day in January

How frequently do we see a minimum temperature below 32 combined with rain in January.

Solution

OAW2309 %>% 
  filter(mo == 1) %>% 
  mutate(bad = TMIN < 32 & PRCP > 0) %>% 
  summarise(mean(bad))
## # A tibble: 1 × 1
##   `mean(bad)`
##         <dbl>
## 1       0.167

Repeat for February

Solution

OAW2309 %>% 
  filter(mo == 2) %>% 
  mutate(bad = TMIN < 32 & PRCP > 0) %>% 
  summarise(mean(bad))
## # A tibble: 1 × 1
##   `mean(bad)`
##         <dbl>
## 1       0.148

March?

Solution

OAW2309 %>% 
  filter(mo == 3) %>% 
  mutate(bad = TMIN < 32 & PRCP > 0) %>% 
  summarise(mean(bad))
## # A tibble: 1 × 1
##   `mean(bad)`
##         <dbl>
## 1       0.116

Rainiest Day

Which days of the year have the highest probability of rain? List them in order of probability.

Solution

OAW2309 %>% 
  group_by(mo, dy) %>% 
  summarize(p_rain = mean(PRCP > 0)) %>% 
  ungroup() %>% 
  arrange(p_rain) %>% 
  tail(10)
## `summarise()` has grouped output by 'mo'. You can override using the `.groups`
## argument.
## # A tibble: 10 × 3
##    mo       dy p_rain
##    <fct> <int>  <dbl>
##  1 1        10  0.720
##  2 11       29  0.720
##  3 12        9  0.720
##  4 12       18  0.720
##  5 12       19  0.720
##  6 11       24  0.732
##  7 12       10  0.732
##  8 12        2  0.744
##  9 2        29  0.75 
## 10 12       20  0.768