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,893 × 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 675aa6786053de6f432eefa8 281622 44100 61829 5990 405 <NULL> 0.399
#> 2 670cd145c3cd67046058015c 76411 16019 23569 318 490 <NULL> 0.529
#> 3 66fff490c3cd670460580111 21114 6920 5481 23 225 <NULL> 0.599
#> 4 66ffdfe3c3cd6704605800fc 54688 19470 7253 644 125 <NULL> 0.503
#> 5 66ffdc31c3cd6704605800ee 26673 4121 7398 126 30 <NULL> 0.438
#> 6 66ffd956c3cd6704605800ec 26673 7039 4039 322 29 <NULL> 0.428
#> 7 66ffbf93c3cd6704605800df 31344 11786 2548 342 91 <NULL> 0.471
#> 8 66f686cfc3cd6704605800a0 64092 20941 2928 754 37 <NULL> 0.385
#> 9 66f68317c3cd67046058009c 749365 264717 40600 13410 638 <NULL> 0.426
#> 10 66d6da9cc3cd670460580053 191809 46549 28802 1905 1012 <NULL> 0.408
#> # ℹ 17,883 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,893 × 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 675aa6786053de6f432eefa8 281622 44100 61829 5990 405 <NULL> 0.399
#> 2 670cd145c3cd67046058015c 76411 16019 23569 318 490 <NULL> 0.529
#> 3 66fff490c3cd670460580111 21114 6920 5481 23 225 <NULL> 0.599
#> 4 66ffdfe3c3cd6704605800fc 54688 19470 7253 644 125 <NULL> 0.503
#> 5 66ffdc31c3cd6704605800ee 26673 4121 7398 126 30 <NULL> 0.438
#> 6 66ffd956c3cd6704605800ec 26673 7039 4039 322 29 <NULL> 0.428
#> 7 66ffbf93c3cd6704605800df 31344 11786 2548 342 91 <NULL> 0.471
#> 8 66f686cfc3cd6704605800a0 64092 20941 2928 754 37 <NULL> 0.385
#> 9 66f68317c3cd67046058009c 749365 264717 40600 13410 638 <NULL> 0.426
#> 10 66d6da9cc3cd670460580053 191809 46549 28802 1905 1012 <NULL> 0.408
#> # ℹ 17,883 more rows