Skip to content

Instantly share code, notes, and snippets.

@thoughtfulbloke
Created May 4, 2020 23:51
Show Gist options
  • Save thoughtfulbloke/473b482c8c83578c948006fc6cdfe964 to your computer and use it in GitHub Desktop.
Save thoughtfulbloke/473b482c8c83578c948006fc6cdfe964 to your computer and use it in GitHub Desktop.
Apple Mobility Data example
library(readr)
library(dplyr)
library(tidyr)
library(lubridate)
library(ggplot2)
# from the downloaded apple mobiblity data of the day
mobl <- read_csv("applemobilitytrends-2020-05-03.csv")
# colums added for each day, so get number of coluns in current data
extant <- ncol(mobl)
# graph specific choices
wanted_regions <- c("New Zealand", "Australia")
wanted_modes <- c("driving", "walking")
mobl %>%
filter(region %in% wanted_regions, transportation_type %in% wanted_modes) %>%
gather(key=Date, value=usage, 5:extant) %>%
mutate(Date = ymd(Date)) %>%
ggplot(aes(x=Date, y=usage, colour=region, linetype=transportation_type)) +
geom_line() + theme_minimal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment