Skip to content

Instantly share code, notes, and snippets.

@bryceroney
Created March 29, 2020 10:07
Show Gist options
  • Save bryceroney/4617652c26f664666227b22095baeef4 to your computer and use it in GitHub Desktop.
Save bryceroney/4617652c26f664666227b22095baeef4 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(lubridate)
data <- read_csv("https://www.data.act.gov.au/api/views/x7dn-77he/rows.csv?accessType=DOWNLOAD")
data <- data %>%
mutate(Date = dmy(Date),
Period = case_when(
Date >= '2020-02-01' & Date <= '2020-02-29' ~ "February",
Date >= '2020-03-01' & Date <= '2020-03-29' ~ "March",
TRUE ~ "Other"
))
l.r<-data %>%
mutate(days_since_som = Date-floor_date(Date, "month")) %>%
mutate(days_since_som = as.numeric(days_since_som)) %>%
filter(Period != "Other") %>%
ggplot(aes(x=days_since_som, y=Total, colour=Period)) +
geom_point(alpha=0.7) +
geom_smooth(se=FALSE, span=0.6) +
labs(
title = "Daily Light Rail Boardings",
subtitle ="February vs March",
caption = "Data source - https://bit.ly/2UOoSx0",
x = "Days since start of month"
) +
scale_color_manual(values=c("#fac3d0", "#f52a59"))
ggsave("C:/temp/lightrailtw.png", l.r, width=30, height=15, units="cm")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment