-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathG4_computations.R
42 lines (30 loc) · 1.49 KB
/
G4_computations.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# G4 - Heizgradtage
# Ab Ende 2024 stehen die Daten nicht mehr über das UGZ Stadt Zürich zur Verfügung
# Alternative suchen (MeteoSchweiz ab April 2025?) und Datenquelle anpassen
# Import data -------------------------------------------------------------
ds <- create_dataset("G4")
ds <- download_data(ds)
g4_data <- ds$data
# Computation: -----------------------------------------------------
# None
# Data structure ----------------------------------------------------------
g4_export_data <- g4_data %>%
dplyr::select(4:ncol(g4_data)) %>%
janitor::row_to_names(16) %>%
dplyr::slice(1) %>%
dplyr::mutate(dplyr::across(.fns = as.numeric)) %>%
tidyr::pivot_longer(cols = everything(), names_to = c("Jahr"), values_to = "Wert") %>%
dplyr::mutate(Gebiet = "Zürich Fluntern",
Einheit = ds$dimension_unit,
Wert = round(Wert, 0)) %>%
# Manually adding columns for Indikator_ID, Indikator_Name, Einheit and Datenquelle
dplyr::mutate(Indikator_ID = ds$dataset_id,
Indikator_Name = ds$indicator_name,
Datenquelle = ds$data_source,
Variable = ds$dataset_name) %>%
dplyr::select(Jahr, Gebiet, Indikator_ID, Indikator_Name, Variable, Wert, Einheit, Datenquelle)
ds$export_data <- g4_export_data
# Export CSV --------------------------------------------------------------
## Temporarily storing export files in Gitea repo > output folder
## Naming convention for CSV files: [indicator number]_data.csv
export_data(ds)