download_apple_mtr_data: Download Apple Mobility Trend Reports Data

View source: R/download_apple_mtr_data.R

download_apple_mtr_dataR Documentation

Download Apple Mobility Trend Reports Data

Description

Provides Mobility Trends Reports related to Covid-19 as provided by Apple (https://www.apple.com/covid19/mobility). Since apple is no longer providing this data since April 14, 2022 the cached data will be returned and calling the function with cache = FALSE will yield an error.

Usage

download_apple_mtr_data(
  type = "country",
  url = NULL,
  silent = FALSE,
  cached = TRUE
)

Arguments

type

The type of data that you want to retrieve. Can be any subset of

  • "country": Mobility trends by country.

  • "country_region": Mobility trends by country regions as classified by Apple (only available for some countries).

  • "country_city": Mobility trends by city as classified by Apple (only available for some countries).

url

The URL of the now defunct Apple Mobility Trend Reports. Ignored.

silent

Whether you want the function to send some status messages to the console. Might be informative as downloading will take some time and thus defaults to TRUE.

cached

Whether you want to download the cached version of the data from the tidycovid19 Github repository. As Apple is no longer provides the data, this needs to be set to TRUE and this is what it defaults to. Will return an error if set to FALSE.

Value

A data frame containing the data. It includes a timestamp variable indicating the time of data retrieval.

Examples

df <- download_apple_mtr_data(silent = TRUE, cached = TRUE)
df %>%
  dplyr::group_by(date) %>%
  dplyr::summarize(
    walking = mean(walking, na.rm = TRUE)
  ) %>%
  ggplot2::ggplot(ggplot2::aes(x = date, y = walking)) +
  ggplot2::geom_line()

df <- download_apple_mtr_data(type = "country_city", silent = TRUE, cached = TRUE)
df %>%
  dplyr::filter(iso3c == "DEU") %>%
  ggplot2::ggplot(ggplot2::aes(x = date, y = driving, color = city)) +
  ggplot2::geom_line()


joachim-gassen/tidycovid19 documentation built on March 21, 2024, 6:57 a.m.