-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (70 loc) · 3.3 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: "Resultate der kantonalen Abstimmungen im Kanton Thurgau ab 2004 nach Gemeinden"
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-52**
# **Resultate der kantonalen Abstimmungen im Kanton Thurgau ab 2004 nach Gemeinden**
[Link to dataset on data.tg.ch](https://data.tg.ch/explore/dataset/sk-stat-52/information/)
## Description
<p>Der Datensatz beinhaltet die Abstimmungsresultate aller kantonalen Abstimmungen ab 2004 auf Gemeindeebene. Nebst dem Datum, dem genauen Wortlaut der Abstimmung und den Ergebnissen (Ja-/Nein-Stimmen) sind in den Daten auch Angaben zum Abstimmungstyp (Volksinitiative, Volksinitiative mit Gegenentwurf, Obligatorisches Referendum, Fakultatives Referendum, Beschluss Grosser Rat), zur Anzahl Stimmberechtigter, den eingelegten Stimmzetteln, den gültigen, ungültigen sowie leeren Stimmen und der Stimmbeteiligung für jede Thurgauer Gemeinde enthalten.</p><p>Datenstand: Abstimmungstag</p>
## Metadata
- **Issued** : 2018-01-18
- **Modified** : 2024-11-01 10:30:06
- **Rights** : CC By 4.0
- **Keywords** : fakultativ, obligatorisch, Abstimmung, Beschluss , Gemeinde , Gemeinden , Politische Gemeinde, Initiative , Kantonale Abstimmung, Referendum , Stimmberechtigte
## 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-52/exports/json")
data <- res$content %>%
rawToChar() %>%
jsonlite::fromJSON()
# Use tgAPI
# data <- tgAPI::get_dataset("sk-stat-52")
head(data)
```
## Explore Metadata
```{r}
res <- httr::GET("https://data.tg.ch/api/explore/v2.0/catalog/datasets/sk-stat-52")
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