Skip to contents

Determines the top-tier (tier = 1L) or second-tier (tier = 2L) topics corresponding to topics in the hierarchy, i.e. either topics themselves or their (grand)parent topics.

Usage

infer_topics(topics, tier = 1L)

Arguments

topics

Topics from which the corresponding (grand)parent topics are to be determined. A factor or character vector.

tier

Tier of the inferred topics. Either 1L or 2L.

Value

A character vector.

See also

Other referendum topic functions: data_topics, hierarchize_topics(), hierarchize_topics_fast(), topics()

Examples

rdb::infer_topics(topics = c("EU", "animal protection"),
                  tier = 1L)
#> [1] "foreign policy"               "environment and living space"
rdb::infer_topics(topics = c("EU", "animal protection"),
                  tier = 2L)
#> [1] "European policy" "environment"    

# topics of different tiers can mixed in `topics`
rdb::infer_topics(topics = c("EU", "environment"),
                  tier = 2L)
#> [1] "European policy" "environment"    

# but `topics` of a higher tier than `tier` will be ignored
rdb::infer_topics(topics = "foreign policy",
                  tier = 2L)
#> character(0)