Skip to contents

Augments data with an additional column country_code_continual holding the current or future ISO 3166-1 alpha-2 code of the country where the referendum took place. If the country still exists, country_code_continual is identical to country_code, otherwise it is the country_code of the successor country. If the country was succeeded by multiple countries, the code of the largest one in terms of population is taken.

Usage

add_country_code_continual(data)

Arguments

data

RDB referendum data as returned by rfrnds(). A data frame that at minimum contains the column country_code (with ISO 3166-1 alpha-2 or ISO 3166-3 alpha-4 codes).

Value

A tibble.

See also

Examples

rdb::rfrnds(quiet = TRUE) |>
  rdb::add_country_code_continual() |>
  dplyr::select(id,
                starts_with("country_"))
#> # A tibble: 17,889 × 4
#>    id                       country_code country_name  country_code_continual
#>    <chr>                    <fct>        <fct>         <fct>                 
#>  1 670cd145c3cd67046058015c CH           Switzerland   CH                    
#>  2 66fff490c3cd670460580111 LI           Liechtenstein LI                    
#>  3 66ffdfe3c3cd6704605800fc CH           Switzerland   CH                    
#>  4 66f686cfc3cd6704605800a0 CH           Switzerland   CH                    
#>  5 66f68317c3cd67046058009c CH           Switzerland   CH                    
#>  6 66d6da9cc3cd670460580053 CH           Switzerland   CH                    
#>  7 66cde603c3cd67046057fff5 CH           Switzerland   CH                    
#>  8 66c46f86c3cd67046057ff53 CH           Switzerland   CH                    
#>  9 66c46cf6c3cd67046057ff4f CH           Switzerland   CH                    
#> 10 66c46c3ac3cd67046057ff4b CH           Switzerland   CH                    
#> # ℹ 17,879 more rows