-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (70 loc) · 2.82 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: "Gesamterneuerungswahl Regierungsrat 2024"
author: "OGD-Koordinationsstelle Kanton Thurgau"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Open Government Data, provided by **Canton Thurgau**
*Autogenerated R starter code for dataset with the identifier* **sk-stat-128**
# **Gesamterneuerungswahl Regierungsrat 2024**
[Link to dataset on data.tg.ch](https://data.tg.ch/explore/dataset/sk-stat-128/information/)
## Description
Der Datensatz beinhaltet die Ergebnisse der Gesamterneuerungswahl des Regierungsrates des Kantons Thurgau 2024 nach Politischen Gemeinden. <br><p>Provisorisches Endergebnis Grossratswahlen 2024 (Stand 07.04.2024)</p>
## Metadata
- **Issued** : 2024-04-06
- **Modified** : 2024-11-01 08:55:21
- **Rights** : CC BY 4.0
- **Keywords** : Regierungsrat, Wahlen, Gesamterneuerungswahl, Gemeinden, Bezirke, Stimmen, Regierungsratswahlen, Regierungsratswahl
## Load Packages
Every dataset (csv and geodata) on [data.tg.ch](https://data.tg.ch/pages/start/) can be retrieved with the **tgAPI** package. You can download it via [GitHub](https://github.com/ogdtg/tgAPI). Please note that the package has some dependencies, which can result in a lengthy installation process. Therefore, we do not recommend installing the package directly in Google Colab. However, if you intend to run this code on your local machine, we strongly recommend installing the tgAPI package.
```{r}
library(httr)
library(jsonlite)
library(dplyr)
# library(remotes)
# remotes::install.github("ogdtg/tgAPI")
```
## Download Data
```{r}
# Download the Dataset via API
res <- httr::GET("https://data.tg.ch/api/explore/v2.0/catalog/datasets/sk-stat-128/exports/json")
data <- res$content %>%
rawToChar() %>%
jsonlite::fromJSON()
# Use tgAPI
# data <- tgAPI::get_dataset("sk-stat-128")
head(data)
```
## Explore Metadata
```{r}
res <- httr::GET("https://data.tg.ch/api/explore/v2.0/catalog/datasets/sk-stat-128")
metadata <- res$content %>%
rawToChar() %>%
jsonlite::fromJSON()
# Fields name
cat("\nFields name")
metadata$dataset$fields$name
# Fields description
cat("\nFields description")
metadata$dataset$fields$description
# Fields data type
cat("\nFields data type")
metadata$dataset$fields$type
```
## Analyze data
```{r}
# Look at the dataset and its structure
summary(data)
```
## Continue your code here...
```{r}
# Do some data magic with R
```
------------------------------------------------------------------------
## Questions about the data?
Contact us via [Mail](mailto:[email protected]) or visit our [GitHub presence](https://github.com/ogdtg)
------------------------------------------------------------------------
OGD-Koordinationsstelle Kanton Thurgau | Grabenstrasse 8 | 8510 Frauenfeld