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

update Google Mobility #3

Merged
merged 1 commit into from
Mar 26, 2022
Merged
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
22 changes: 13 additions & 9 deletions data_preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ URL_Basis_wetter <- "https://data.stadt-zuerich.ch/dataset/ugz_meteodaten_tagesm
path_wetter <- "data/wetter_"

#Google
URL_google <- "https://storage.googleapis.com/covid19-open-data/v2/CH_ZH/main.csv"
URL_google <- "https://storage.googleapis.com/covid19-open-data/v3/mobility.csv"


#________________________________________________________________
Expand Down Expand Up @@ -664,15 +664,19 @@ data_wetter<-dcast(data_wetter, date~Parameter )%>%

#### > Google Mobilität ####

google_mobility <- read.csv(URL_google,
stringsAsFactors = FALSE,
encoding = 'UTF-8')
#Daten von Google beziehen (Komplett, ungefiltert da es derzeit(?) nicht möglich ist einen key
#in der URL mitzugeben wie eigentlich hier beschrieben https://github.com/GoogleCloudPlatform/covid-19-open-data)

google_mobility <- data.table::fread(URL_google,
na.strings = c("", "NA", "#N/A"))%>%
filter(location_key=="CH_ZH")


#Divese umformatierungen/selektionen
google_mobility_reduced <- google_mobility%>%
#Datum umwandeln
mutate(date=as.Date(as.POSIXct(date)))%>%
#Jede Menge Spalten welche hierfür uninteressant sind
#Nur die relevanten Spalten behalten
select(date,
mobility_retail_and_recreation,
mobility_grocery_and_pharmacy,
Expand Down Expand Up @@ -741,7 +745,7 @@ fwrite(mobility_index,
"mobility_index.csv",
row.names = FALSE)

fwrite(geo_info,
"geo_info.csv",
row.names = FALSE,
quote = TRUE)
# fwrite(geo_info,
# "geo_info.csv",
# row.names = FALSE,
# quote = TRUE)