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.
download_google_cmr_data(type = "country", silent = FALSE, cached = FALSE)
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.
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
.
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
.
If only one type
was selected, a data frame containing the
data. Otherwise, a list containing the desired data frames ordered as
in type
.
# 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