-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.qmd
80 lines (59 loc) · 2.12 KB
/
index.qmd
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
---
title: "StatePol"
subtitle: "The most comprehensive Database on German State Politicians"
---
StatePol introduces a publicly available database on the members of German state parliaments and governments. This resource offers detailed information about the personal attributes of German state politicians, along with their roles and positions in both legislative and executive settings, spanning from 1990 to 2020.
::: columns
::: {.column width="60%"}
{fig-align="center"}
:::
::: {.column width="40%"}
## What's in the Database?
- 111 terms in the 16 state parliaments
- 6977 individual legislators
- 21.517.423 daily observations
- 148 state cabinets
- 920 individual cabinet members
- 2.223.995 daily observations
## Access the Database
To access the data please refer to the instruction on the [download](download.qmd) page.
:::
:::
```{r version_name_control, echo=FALSE, warning=FALSE, message=FALSE}
## packages
library(downloadthis)
library(tidyverse)
library(rio)
### VERSION NAMING EXCLUDED ###
# data directory
data_dir <- "_data/database"
# define version to append
new_version <- paste0('_', readLines('VERSION')[1])
# regular expression to match version pattern
version_pattern <- "_[0-9]+\\.[0-9]+\\.[0-9]+" # Matches "_1.0.0", "_2.1.3", etc.
# list all csv files
files <- list.files(data_dir, pattern = "\\.csv$", full.names = TRUE)
# loop and rename files
for (file in files) {
# define filename
original_name <- basename(file)
# check if already contains a version
if (grepl(version_pattern, original_name)) {
# if yes, replace with new version
new_name <- sub(version_pattern, new_version, original_name)
} else {
# if no version append
new_name <- sub("\\.csv$", paste0(new_version, ".csv"), original_name)
}
# define full new path
new_full_path <- file.path(dirname(file), new_name)
# rename only if the name differs
if (original_name != new_name) {
if (file.rename(file, new_full_path)) {
cat("Renamed:", original_name, "to", new_name, "\n")
} else {
}
} else {
}
}
```