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,866 × 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 6694f97dc3cd67046057fed1 224332 60582 45908 3655 496 <NULL> 0.493
#> 2 66856a7bc3cd67046057fe61 1692379 356944 335183 NA 8759 <NULL> 0.414
#> 3 66856972c3cd67046057fe5a 1692380 462292 230724 NA 7923 <NULL> 0.414
#> 4 66856835c3cd67046057fe53 1692373 486516 199744 NA 14593 <NULL> 0.414
#> 5 66856659c3cd67046057fe4b 1692371 378917 311429 NA 10651 <NULL> 0.414
#> 6 6659b208c3cd67046057fe31 108099 24182 22432 866 50 <NULL> 0.440
#> 7 6659b140c3cd67046057fe2d 51893 12831 19743 2419 23 <NULL> 0.675
#> 8 6659af29c3cd67046057fe29 280302 27262 89055 12721 141 <NULL> 0.461
#> 9 6659ae82c3cd67046057fe25 280302 51787 68458 8793 141 <NULL> 0.461
#> 10 6659ad59c3cd67046057fe21 280302 47922 74596 6529 141 <NULL> 0.461
#> # ℹ 17,856 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,866 × 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 6694f97dc3cd67046057fed1 224332 60582 45908 3655 496 <NULL> 0.493
#> 2 66856a7bc3cd67046057fe61 1692379 356944 335183 NA 8759 <NULL> NA
#> 3 66856972c3cd67046057fe5a 1692380 462292 230724 NA 7923 <NULL> NA
#> 4 66856835c3cd67046057fe53 1692373 486516 199744 NA 14593 <NULL> NA
#> 5 66856659c3cd67046057fe4b 1692371 378917 311429 NA 10651 <NULL> NA
#> 6 6659b208c3cd67046057fe31 108099 24182 22432 866 50 <NULL> 0.440
#> 7 6659b140c3cd67046057fe2d 51893 12831 19743 2419 23 <NULL> 0.675
#> 8 6659af29c3cd67046057fe29 280302 27262 89055 12721 141 <NULL> 0.461
#> 9 6659ae82c3cd67046057fe25 280302 51787 68458 8793 141 <NULL> 0.461
#> 10 6659ad59c3cd67046057fe21 280302 47922 74596 6529 141 <NULL> 0.461
#> # ℹ 17,856 more rows