From the Google website: These Community Mobility Reports aim to provide insights into what has changed in response to policies aimed at combating COVID-19. 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_mobility_data(accept_terms = TRUE, nrows = Inf)

Arguments

accept_terms

default is TRUE, but please make sure that you and any downstream users are aware that they are accepting Google's terms of service. See the note below.

nrows

default is Inf, but specify a smaller number to limit memory usage. This dataset is HUGE.

Value

a data.frame

Details

From Google:

What’s a Community Mobility Report?

Each Community Mobility Report is broken down by location and displays the percent change from baseline in visits to places like grocery stores and parks.

Note

Using this function implies that you agree to the Google terms of service: https://policies.google.com/terms

Privacy

Google provides this explanation with regard to preserving privacy:

The Community Mobility Reports were developed to be helpful while adhering to our stringent privacy protocols and protecting people’s privacy. No personally identifiable information, such as an individual’s location, contacts or movement, will be made available at any point.

Insights in these reports are created with aggregated, anonymized sets of data from users who have turned on the Location History setting, which is off by default. People who have Location History turned on can choose to turn it off at any time from their Google Account and can always delete Location History data directly from their Timeline.

We also use the same world-class anonymization technology used in our products every day to keep your activity data private and secure. This includes differential privacy, which adds artificial noise to our datasets, enabling us to generate insights while preventing the identification of any individual person.

Author

Sean Davis seandavi@gmail.com

Examples


# requires significant memory to run

if (FALSE) {
res = google_mobility_data(nrows=1000000)
colnames(res)
head(res)
dplyr::glimpse(res)

# analyze the "admin levels" available for each
# country:

admin_by_country = res %>%
    dplyr::group_by(iso2c) %>%
    dplyr::filter(date == max(date))
admin_by_country = table(admin_by_country$admin_level, 
                         admin_by_country$iso2c)/length(unique(res$places_category))
admin_by_country

# Italy mobility over time
# Note day-of week effect in plot

library(ggplot2)

res %>%
## Italy, whole country(admin == 0)
    dplyr::filter(iso2c == "IT" & admin_level==0) %>%
    ggplot(aes(x=date,y=percent_change_from_baseline,color = places_category)) +
    geom_line() +
    ggtitle('Google mobility metric for Italy') +
    theme(legend.position='bottom')
}