forked from hdigital/ess-linking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpf-harmonization.qmd
58 lines (44 loc) · 1.26 KB
/
pf-harmonization.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
# Party Facts harmonization
Information on Party Facts ESS party IDs harmonization – see also sections "Linking data sets with Party Facts" and "ESS party data structure" in manuscript.
```{r}
library(conflicted)
library(tidyverse)
conflicts_prefer(dplyr::filter, .quiet = TRUE)
library(knitr)
library(reactable)
```
```{r}
pf_raw <- read_csv("data-raw/pf-essprtv.csv")
pf <- pf_raw |> rename(cntry = ess_cntry)
```
## ESS party IDs
Party Facts (PF) harmonizes ESS party IDs by creating a unique ESS party id (_"first_ess_id"_) for all ESS rounds. — see [PF GitHub // _essprtv_](https://github.com/hdigital/partyfactsdata/tree/main/import/essprtv)
```{r}
pf |>
mutate(prt_variable = str_extract(ess_variable, "[:alpha:]{4}")) |>
summarise(
n_ess_parties = n_distinct(ess_id),
n_harmonized = n_distinct(first_ess_id),
.by = prt_variable
)
```
## Parties per country
```{r}
tbl <-
pf |>
summarise(
n_essrounds = n_distinct(essround),
n_ess_parties = n(),
n_harmonized = n_distinct(first_ess_id),
.by = cntry
) |>
arrange(cntry)
```
Number of ESS party IDs and harmonized IDs in ESS rounds by country (_prtv_ and _prtc_)
```{r}
if (knitr::is_html_output()) {
tbl |> reactable(searchable = TRUE, striped = TRUE)
} else {
tbl
}
```