knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Let's load the cached data, and filter down to the United States of America.

library(covid19mobility)
library(dplyr)

#if you want to try this with fresh data
# us_mobile <- refresh_covid19mobility_apple_country() %>%
#   filter(location_code == "US")

us_mobile <- covid19mobility_apple_country_demo %>%
  filter(location_code == "US")

Now, let's plot it!

library(ggplot2)


ggplot(us_mobile,
       aes(x = date, y = value, color = data_type)) +
  geom_line(size = 1) +
  theme_bw(base_size=14) +
  labs(color = "Mobility Type",
       y = "Relative Value",
       x = "") +
  ggtitle("Apple Mobility Trends")


Covid19R/covid19mobility documentation built on March 11, 2021, 12:46 p.m.