-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboulder_weather.Rmd
More file actions
76 lines (65 loc) · 2.27 KB
/
boulder_weather.Rmd
File metadata and controls
76 lines (65 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "Boulder Weather Time Series"
subtitle: "Data from NOAA: https://observablehq.com/@observablehq/noaa-weather-data-by-major-u-s-city"
author: "Spencer Zeigler"
date: "Last knitted `r format(Sys.Date(), '%d %b %Y')`"
output:
html_document:
df_print: paged
number_sections: yes
toc: yes
toc_float: true
toc_depth: 3
code_folding: show
editor_options:
chunk_output_type: console # switch to 'inline' if preferred
---
# Setup
```{r "setup", message = FALSE}
# packages
library(tidyverse) # general data wrangling and plotting
library(see)
library(ggridges)
# global knitting options for code rendering
knitr::opts_chunk$set(
collapse = TRUE, comment = "#>",
dev = c("png", "pdf"),
dev.args = list(pdf = list(encoding = "WinAnsi", useDingbats = FALSE)),
fig.keep = "all",
fig.path = file.path("plots", paste0(gsub("\\.[Rr]md", "", knitr::current_input()), "_"))
)
```
# Data Loading
```{r}
weather_raw <- read_csv("data/Boulder_2020.csv")
weather <- weather_raw %>%
mutate(date = lubridate::ymd_hms(weather_raw$date),
air_temp = air_temp * (9/5) + 32,
month = lubridate::month(weather_raw$date))
```
# Monthly weather plotting
```{r}
weather %>%
group_by(month) %>%
ggplot(aes(x = air_temp, y = as_factor(month), fill = stat(x))) +
geom_density_ridges_gradient() +
scale_fill_viridis_c(option = "C", direction = -1, begin = 1, end = 0) +
theme_minimal() +
theme(axis.line.x.bottom = element_line(),
axis.line.y.left = element_line(),
panel.grid = element_blank(),
axis.ticks.x = element_line(),
legend.position = "none",
axis.text = element_text(family = "Avenir"),
axis.title.y.left = element_text(margin = margin(l = 5)),
axis.title.x.bottom = element_text(margin = margin(t = 5)),
axis.title = element_text(family = "Avenir"),
plot.title = element_text(family = "Avenir", margin = margin(b = 10, t = 5)),
plot.caption = element_text(family = "Avenir", margin = margin(t=10, b = 5))
) +
labs(title = "Monthly Temperatures for 2020 in Boulder, CO",
x = "Temperature [°F]",
y = "Month",
caption = "Source: NOAA Weather DataBy Major City\nObservableHQ | 19-10-2021") +
scale_y_discrete(labels = month.name)
```