This is an explanation of what I was looking for in Problem 1 of the last assignment.
First, let’s do the existing graph in the notes.
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4
## ✓ tibble 3.0.6 ✓ dplyr 1.0.4
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
load("olyw1018.RData")
olyw1018 %>%
group_by(mo,dy) %>%
summarize(prain = mean(PRCP > 0),
dmax = mean(TMAX),
midmax = median(TMAX),
dmin = mean(TMIN)) %>%
ungroup() %>%
mutate(date =make_date(2020,mo,dy))-> cal20
## `summarise()` has grouped output by 'mo'. You can override using the `.groups` argument.
cal20 %>% ggplot(aes(x=date,y=dmax)) +
geom_point(alpha=.5,size=.5) +
ggtitle("Average Daily Maximum Temperature") +
theme(plot.title = element_text(hjust = 0.5)) -> v0
ggplotly(v0)
Using as much of my code as you need, replicate my graph showing the mean value of the daily maximum temperature with the following changes for every calendar day.
Use the median, the minimum, and the maximum instead of the mean. Give them different colors, but don’t bother with a legend.
Fix the date display so that no specific year appears.
olyw1018 %>%
group_by(mo,dy) %>%
summarize(minTMAX = min(TMAX),
medianTMAX = median(TMAX),
maxTMAX = max(TMAX) ) %>%
ungroup() %>%
mutate(date =make_date(2020,mo,dy))-> cal20
## `summarise()` has grouped output by 'mo'. You can override using the `.groups` argument.
cal20 %>% ggplot(aes(x=date)) +
geom_point(alpha=.5,size=.5,aes(y = minTMAX),color = "red") +
geom_point(alpha=.5,size=.5,aes(y = medianTMAX),color = "green") +
geom_point(alpha=.5,size=.5,aes(y = maxTMAX),color = "blue") +
ggtitle("Min, Median, and max of Daily Maximum Temperature") +
theme(plot.title = element_text(hjust = 0.5)) +
scale_x_date(date_labels = "%b")-> v0
ggplotly(v0)