Augments data
with an additional column turnout
containing the voter turnout calculated as:
Arguments
- data
RDB referendum data as returned by
rfrnds()
. A data frame that at minimum contains the columnselectorate_total
,votes_yes
,votes_no
,votes_empty
andvotes_invalid
.- rough
Whether to fall back on a "rough" calculation of the turnout in case any of the variables
votes_empty
orvotes_invalid
is unknown (NA
), or to be strict and returnNA
in such a case.- excl_dubious
Whether or not to exclude obviously dubious turnout numbers (those > 1.0) by setting them to
NA
. Such numbers stem either from data errors or (officially) tampered numbers.
Value
A tibble.
See also
Other referendum data augmentation functions:
add_country_code_continual()
,
add_country_code_long()
,
add_country_name()
,
add_country_name_long()
,
add_former_country_flag()
,
add_period()
,
add_urls()
,
add_world_regions()
Examples
# rough turnout numbers
rdb::rfrnds(quiet = TRUE) |>
rdb::add_turnout() |>
dplyr::select(id,
electorate_total,
starts_with("votes_"),
turnout)
#> # A tibble: 17,889 × 8
#> id electorate_total votes_yes votes_no votes_empty votes_invalid votes_per_subterritory turnout
#> <chr> <int> <int> <int> <int> <int> <list> <dbl>
#> 1 670cd145c3cd67046058015c 76411 16019 23569 318 490 <NULL> 0.529
#> 2 66fff490c3cd670460580111 21114 6920 5481 23 225 <NULL> 0.599
#> 3 66ffdfe3c3cd6704605800fc 54688 19470 7253 644 125 <NULL> 0.503
#> 4 66f686cfc3cd6704605800a0 64092 20941 2928 754 37 <NULL> 0.385
#> 5 66f68317c3cd67046058009c 749365 264717 40600 13410 638 <NULL> 0.426
#> 6 66d6da9cc3cd670460580053 191809 46549 28802 1905 1012 <NULL> 0.408
#> 7 66cde603c3cd67046057fff5 142124 42607 12563 1037 720 <NULL> 0.401
#> 8 66c46f86c3cd67046057ff53 108212 27024 25152 424 30 <NULL> 0.486
#> 9 66c46cf6c3cd67046057ff4f 183598 49060 20304 2644 930 <NULL> 0.397
#> 10 66c46c3ac3cd67046057ff4b 183598 51469 17569 2793 936 <NULL> 0.396
#> # ℹ 17,879 more rows
# strict turnout numbers
rdb::rfrnds(quiet = TRUE) |>
rdb::add_turnout(rough = FALSE) |>
dplyr::select(id,
electorate_total,
starts_with("votes_"),
turnout)
#> # A tibble: 17,889 × 8
#> id electorate_total votes_yes votes_no votes_empty votes_invalid votes_per_subterritory turnout
#> <chr> <int> <int> <int> <int> <int> <list> <dbl>
#> 1 670cd145c3cd67046058015c 76411 16019 23569 318 490 <NULL> 0.529
#> 2 66fff490c3cd670460580111 21114 6920 5481 23 225 <NULL> 0.599
#> 3 66ffdfe3c3cd6704605800fc 54688 19470 7253 644 125 <NULL> 0.503
#> 4 66f686cfc3cd6704605800a0 64092 20941 2928 754 37 <NULL> 0.385
#> 5 66f68317c3cd67046058009c 749365 264717 40600 13410 638 <NULL> 0.426
#> 6 66d6da9cc3cd670460580053 191809 46549 28802 1905 1012 <NULL> 0.408
#> 7 66cde603c3cd67046057fff5 142124 42607 12563 1037 720 <NULL> 0.401
#> 8 66c46f86c3cd67046057ff53 108212 27024 25152 424 30 <NULL> 0.486
#> 9 66c46cf6c3cd67046057ff4f 183598 49060 20304 2644 930 <NULL> 0.397
#> 10 66c46c3ac3cd67046057ff4b 183598 51469 17569 2793 936 <NULL> 0.396
#> # ℹ 17,879 more rows