Reconstructs the hierarchical relations between the three topic variables topics_tier_1
, topics_tier_2
and topics_tier_3
. Other than
hierarchize_topics()
, this function assumes that the three topic variables are always complete, i.e. that no (grand)parent topics of lower-tier topics
are missing. This assumption is met by rfrnds()
and rfrnd()
.
Value
A tibble with the columns topic_tier_1
, topic_tier_2
and topic_tier_3
.
See also
Other referendum topic functions:
data_topics
,
hierarchize_topics()
,
infer_topics()
,
topics()
Examples
library(magrittr)
rdb::rfrnd(id = "5bbbe26a92a21351232dd73f") %$%
rdb::hierarchize_topics_fast(unlist(topics_tier_1),
unlist(topics_tier_2),
unlist(topics_tier_3))
#> # A tibble: 3 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 state organisation federalism intergovernmental relations
#> 2 state organisation legal system fundamental rights
#> 3 public finance taxation tax system
# hierarchize the topics of all Austrian referendums
rdb::rfrnds(quiet = TRUE) |>
dplyr::filter(country_code == "AT") |>
dplyr::group_split(id) |>
purrr::map(~ rdb::hierarchize_topics_fast(unlist(.x$topics_tier_1),
unlist(.x$topics_tier_2),
unlist(.x$topics_tier_3)))
#> [[1]]
#> # A tibble: 2 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 state organisation federalism territorial questions
#> 2 state organisation national identity NA
#>
#> [[2]]
#> # A tibble: 0 × 3
#> # ℹ 3 variables: topic_tier_1 <chr>, topic_tier_2 <chr>, topic_tier_3 <chr>
#>
#> [[3]]
#> # A tibble: 1 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 state organisation national identity NA
#>
#> [[4]]
#> # A tibble: 1 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 state organisation national identity NA
#>
#> [[5]]
#> # A tibble: 2 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 state organisation federalism territorial questions
#> 2 state organisation national identity NA
#>
#> [[6]]
#> # A tibble: 2 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 state organisation federalism territorial questions
#> 2 state organisation national identity NA
#>
#> [[7]]
#> # A tibble: 3 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 state organisation federalism territorial questions
#> 2 state organisation national identity NA
#> 3 state organisation political system NA
#>
#> [[8]]
#> # A tibble: 1 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 energy nuclear energy NA
#>
#> [[9]]
#> # A tibble: 1 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 foreign policy European policy EU
#>
#> [[10]]
#> # A tibble: 1 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 security policy army military organisation
#>
#> [[11]]
#> # A tibble: 1 × 3
#> topic_tier_1 topic_tier_2 topic_tier_3
#> <chr> <chr> <chr>
#> 1 security policy army military organisation
#>