Explore OAW23

Harold Nelson

2023-02-15

Setup

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6      ✔ purrr   0.3.4 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.2      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
load("OAW23.Rdata")
glimpse(OAW23)
## Rows: 29,839
## Columns: 7
## $ DATE <date> 1941-05-13, 1941-05-14, 1941-05-15, 1941-05-16, 1941-05-17, 1941…
## $ PRCP <dbl> 0.00, 0.00, 0.30, 1.08, 0.06, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,…
## $ TMAX <dbl> 66, 63, 58, 55, 57, 59, 58, 65, 68, 85, 84, 75, 72, 59, 61, 59, 6…
## $ TMIN <dbl> 50, 47, 44, 45, 46, 39, 40, 50, 42, 46, 46, 50, 41, 37, 48, 46, 4…
## $ yr   <dbl> 1941, 1941, 1941, 1941, 1941, 1941, 1941, 1941, 1941, 1941, 1941,…
## $ mo   <fct> 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6,…
## $ dy   <int> 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 2…

Warming?

Use this data to consider the possibility that weather in Olympia has been getting warmer.

Solution

OAW23 %>% 
  ggplot(aes(x = yr, y = TMAX)) +
  geom_point() +
  geom_smooth()
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'

cor(OAW23$yr,OAW23$TMAX)
## [1] 0.01632567

Compare

Compare the weather for today with the weather one month ago and one month in the future.

Solution

three_days = OAW23 %>% 
  filter(mo %in% c(1,2,3),
         dy == 15)

three_days %>% 
  ggplot(aes(x = mo, y = TMAX)) +
  geom_boxplot() + 
  ggtitle("TMAX Values")

three_days %>% 
  ggplot(aes(x = mo, y = PRCP)) +
  geom_boxplot() + 
  ggtitle("PRCP Values")

three_days %>% 
  group_by(mo) %>% 
  summarize(mean_PRCP = mean(PRCP),
            mean_TMAX = mean(TMAX))
## # A tibble: 3 × 3
##   mo    mean_PRCP mean_TMAX
##   <fct>     <dbl>     <dbl>
## 1 1         0.245      45.1
## 2 2         0.249      48.6
## 3 3         0.197      53.4

Another Comparison

Describe the weather on the 15th of every month.

Solution

fifteenth = OAW23 %>% 
  filter(dy == 15)

fifteenth %>% 
  ggplot(aes(x = mo, y = TMAX)) +
  geom_boxplot() + 
  ggtitle("TMAX Values")

fifteenth %>% 
  ggplot(aes(x = mo, y = PRCP)) +
  geom_boxplot() + 
  ggtitle("PRCP Values")

fifteenth %>% 
  group_by(mo) %>% 
  summarize(mean_PRCP = mean(PRCP),
            mean_TMAX = mean(TMAX)) 
## # A tibble: 12 × 3
##    mo    mean_PRCP mean_TMAX
##    <fct>     <dbl>     <dbl>
##  1 1        0.245       45.1
##  2 2        0.249       48.6
##  3 3        0.197       53.4
##  4 4        0.105       58.9
##  5 5        0.106       66.3
##  6 6        0.0471      69.6
##  7 7        0.0201      77  
##  8 8        0.0395      77.8
##  9 9        0.0988      70.3
## 10 10       0.104       62.0
## 11 11       0.236       50.7
## 12 12       0.263       45.2