Free Access Week-  Data Engineering + BI
Data engineering and BI courses are free!
Free AI Access Week from June 2-8

tidycovid19 (version 0.0.0.9000)

download_google_cmr_data: Download Google Community Mobility Reports Data

Description

Downloads Google Community Mobility Report data (https://www.google.com/covid19/mobility/). As stated on this webpage, the "reports chart movement trends over time by geography, across different categories of places such as retail and recreation, groceries and pharmacies, parks, transit stations, workplaces, and residential". Google prepares these reports to help interested parties to assess responses to social distancing guidance related to Covid-19.

Usage

download_google_cmr_data(type = "country", silent = FALSE, cached = FALSE)

Arguments

type

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

  • "country": Movement trends by country.

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

  • "country_sub_region": Movement trends by country sub-regions as classified by Google (only available for some countries).

  • "us_county": Movement trends at the U.S. county level.

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 instead of retrieving the data from the authorative source. Downloading the cached version is faster and the cache is updated daily. Defaults to FALSE.

Value

If only one type was selected, a data frame containing the data. Otherwise, a list containing the desired data frames ordered as in type.

Examples

Run this code
# NOT RUN {
df <- download_google_cmr_data(silent = TRUE, cached = TRUE)
df %>%
  dplyr::group_by(date) %>%
  dplyr::summarize(
    retail_recreation = mean(retail_recreation, na.rm = TRUE)
  ) %>%
  ggplot2::ggplot(ggplot2::aes(x = date, y = retail_recreation)) +
  ggplot2::geom_line()

df <- download_google_cmr_data(type = "country_region", silent = TRUE, cached = TRUE)
df %>%
  dplyr::filter(iso3c == "USA") %>%
  dplyr::select(-iso3c) %>%
  dplyr::group_by(region) %>%
  dplyr::summarise(`Retail and Recreation Effect` =
     max(retail_recreation, na.rm = TRUE) -
     min(retail_recreation, na.rm = TRUE)) %>%
  dplyr::rename(`U.S. State` = region) %>%
  dplyr::arrange(-`Retail and Recreation Effect`)

# }

Run the code above in your browser using DataLab