--- title: "Week 14 Web Scraping" author: "Katie Fitzgerald" date: "`r Sys.Date()`" format: html: self-contained: true toc: true toc_float: true number_section: false highlight: "tango" theme: "cosmo" editor: visual editor_options: chunk_output_type: console --- ```{r, message=FALSE} library(tidyverse) library(scales) library(geomtextpath) ``` ```{r} statepop <- read_rds("data/statepop_2020.RDS") states <- map_data("state") statepop |> mutate(state = str_to_lower(state)) |> right_join(states, by = c("state" = "region")) |> mutate(pop2020_mil = pop2020/1000000) |> ggplot(aes(x = long, y = lat, group = group, fill = pop2020_mil)) + geom_polygon() + labs(fill = "Population \nin millions") + theme_void() + coord_fixed(1.3) ``` # PSSA ```{r} pssa <- read_rds("data/pssa_2025.RDS") ggplot(pssa, aes(x = grade, y = percent_proficient_and_above, color = subject)) + geom_line() + theme(legend.position = "bottom") ``` # Olympics ```{r} olympics <- read_rds("data/olympics.RDS") |> mutate(time = parse_number(time), date = ymd(date)) ggplot(olympics, aes(x = date, y = time, color = sex)) + geom_line() + geom_labelpath(aes(label = sex)) + scale_x_date(breaks = seq(as.Date("1890-01-01"), as.Date("2020-01-01"), by = "10 years"), date_labels = "%Y") + theme_minimal() + theme(legend.position = "none") + labs(title = "Olympic Records (100m Dash)", y = "Time (in seconds)", x = "Year") #alternative olympics <- olympics |> mutate(year = year(date)) olympics |> ggplot(aes(x = year, y = time, color = sex)) + geom_line() + geom_labelpath(aes(label = sex)) + scale_x_continuous(breaks = seq(1890, 2020, by = 10)) + theme_minimal() + theme(legend.position = "none") + labs(title = "Olympic Records (100m Dash)", y = "Time (in seconds)", x = "Year") ```