DK
Size: a a a
DK
AS
БА
DK
БА
М
DK
БА
DK
S
IY
S
ГД
DP
N
AS
AS
AS
DP
Ю
library(tidyverse)
cdn_url <- "https://covid19-static.cdn-apple.com"
json_file <- "covid19-mobility-data/current/v3/index.json"
tf <- tempfile(fileext = ".json")
curl::curl_download(paste0(cdn_url, "/", json_file), tf)
json_data <- jsonlite::fromJSON(tf)
csv_url <- paste0(cdn_url, json_data$basePath, json_data$regions$`en-us`$csvPath)
date_csv_data <- stringr::str_extract(csv_url, "\\d{4}-\\d{2}-\\d{2}")
mobility <- readr::read_csv(csv_url)
write.csv2(mobility, paste0("data_raw/apple_mobility_data_", date_csv_data, ".csv"), na = "", row.names = FALSE)
names(mobility)[1:6] <- c(
"geo_type",
"region",
"transportation_type",
"alternative_name",
"sub_region",
"country"
)
mobility <- gather(mobility, date, index,
-geo_type, -region, -transportation_type,
-alternative_name, -sub_region, -country)
mobility$date <- as.Date(mobility$date, "%Y-%m-%d")