Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch Google's global mobility report #110

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ Brazil/figures/*.pdf
Brazil/figures/*.txt
Brazil/results/*.RDS

# No data files
data/*.csv
Brazil/data/*.csv
Italy/data/*.csv


# Python
Expand Down
4 changes: 2 additions & 2 deletions Brazil/code/preprocessing-subnation-brazil.r
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ df=df[order(as.Date(df$DateRep, format="%Y-%m-%d")),]
write_csv(df,"Brazil/data/df-Brazil.csv")

#### Adding google mobility data
mobility.aux = read.csv(paste0(path,"/Global-Mobility-Report.csv"))
mobility.aux = read.csv("data/Global_Mobility_Report.csv"))
mobility.aux2 = subset(mobility.aux,mobility.aux$country_region=="Brazil")
mobility.aux2 = mobility.aux2[which(mobility.aux2$sub_region_1!=""),]

Expand Down Expand Up @@ -222,4 +222,4 @@ process_data <- function(countries,N2,d){

return(list("stan_data" = stan_data, "dates" = dates, "reported_cases"=reported_cases, "deaths_by_country" = deaths_by_country))

}
}
308,328 changes: 0 additions & 308,328 deletions Brazil/data/Global-Mobility-Report.csv

This file was deleted.

2 changes: 1 addition & 1 deletion Italy/code/utils/read-data-subnational.r
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ read_ifr_data <- function(regions){
}

read_google_mobility <- function(Country){
google_mobility <- read.csv('Italy/data/Global_Mobility_Report.csv', stringsAsFactors = FALSE)
google_mobility <- read.csv('data/Global_Mobility_Report.csv', stringsAsFactors = FALSE)
google_mobility$date = as.Date(google_mobility$date, format = '%Y-%m-%d')
google_mobility[, c(6,7,8,9,10,11)] <- google_mobility[, c(6,7,8,9,10,11)]/100
google_mobility[, c(6,7,8,9,10)] <- google_mobility[, c(6,7,8,9,10)] * -1
Expand Down
284,490 changes: 0 additions & 284,490 deletions Italy/data/Global_Mobility_Report.csv

This file was deleted.

16 changes: 16 additions & 0 deletions data/fetch-ecdc.r → data/fetch-data.r
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ names(d)[names(d) == "deaths"] <- "Deaths"
names(d)[names(d) == "cases"] <- "Cases"
names(d)[names(d) == "dateRep"] <- "DateRep"
saveRDS(d, "data/COVID-19-up-to-date.rds")

# Download Google's mobility report
url <- "https://www.gstatic.com/covid19/mobility/Global_Mobility_Report.csv"
url_page <- "https://www.google.com/covid19/mobility/"
tryCatch({
r <- RETRY("GET", url,
write_disk("data/Global_Mobility_Report.csv", overwrite=TRUE))

if (http_error(r)) {
stop("Error downloading file")
}
},
error = function(e) {
stop(sprintf("Error downloading file '%s': %s, please check %s",
url, e$message, url_page))
})
2 changes: 1 addition & 1 deletion web-fetch-and-run.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# print("Fetching data from ECDC")
# fetch_ecdc_error <- system("Rscript data/fetch-ecdc.r",intern=FALSE)
# fetch_ecdc_error <- system("Rscript data/fetch-data.r",intern=FALSE)
# if(fetch_ecdc_error != 0){
# stop(sprintf("Error while fetching data from the ECDC! Code: %d", fetch_ecdc_error))
# }
Expand Down