Skip to contents

Renames referendum data column names to be ready for publication. Useful e.g. to create tables or visualizations.

Usage

prettify_col_names(data)

Arguments

data

RDB referendum data as returned by rfrnds().

Value

A tibble.

Details

Note that

  • column names unknown to this function are not changed.

  • column labels are removed so they aren't inadvertently used instead of the column names (i.a. relevant for gt >= 0.9.0).

See also

Other referendum data transformation functions: as_ballot_dates(), n_rfrnds(), n_rfrnds_per_period(), unnest_var()

Other functions to prettify names: prettify_var_names()

Examples

rdb::rfrnds(quiet = TRUE) |>
  rdb::prettify_col_names()
#> # A tibble: 17,893 × 67
#>    `RDB ID`     `Official ID` `sudd.ch ID` ISO 3166-1 alpha-2 /…¹ Country `Subnational entity` Municipality `Political level` Date       `Former country?` Title
#>    <chr>        <chr>         <chr>        <fct>                  <fct>   <chr>                <chr>        <ord>             <date>     <lgl>             <chr>
#>  1 675aa678605… NA            NA           CH                     Switze… Geneva               NA           subnational       2024-09-22 NA                An A…
#>  2 670cd145c3c… NA            NA           CH                     Switze… Zug                  NA           subnational       2024-06-09 NA                Cycl…
#>  3 66fff490c3c… NA            NA           LI                     Liecht… NA                   NA           national          2024-09-22 NA                Refe…
#>  4 66ffdfe3c3c… NA            NA           CH                     Switze… Jura                 NA           subnational       2024-09-22 NA                Act …
#>  5 66ffdc31c3c… NA            NA           CH                     Switze… Uri                  NA           subnational       2024-09-22 NA                Ener…
#>  6 66ffd956c3c… NA            NA           CH                     Switze… Uri                  NA           subnational       2024-09-22 NA                Part…
#>  7 66ffbf93c3c… NA            NA           CH                     Switze… Nidwalden            NA           subnational       2024-09-22 NA                Amen…
#>  8 66f686cfc3c… NA            NA           CH                     Switze… Bern                 NA           subnational       2024-09-22 NA                Conc…
#>  9 66f68317c3c… NA            NA           CH                     Switze… Bern                 NA           subnational       2024-09-22 NA                Amen…
#> 10 66d6da9cc3c… NA            NA           CH                     Switze… Basel Landschaft     NA           subnational       2024-09-22 NA                Part…
#> # ℹ 17,883 more rows
#> # ℹ abbreviated name: ¹​`ISO 3166-1 alpha-2 / ISO 3166-3 alpha-4`
#> # ℹ 56 more variables: Titel <chr>, Titre <chr>, `Original question` <chr>, Question <chr>, `Committee name` <chr>, Result <fct>,
#> #   `Approving subterritories` <dbl>, `Rejecting subterritories` <dbl>, `Total electorate` <int>, `Electorate abroad` <int>, `Yes votes` <int>,
#> #   `No votes` <int>, `Empty votes` <int>, `Invalid votes` <int>, `Subterritorial votes` <list>, `Lower house yes votes` <int>, `Lower house no votes` <int>,
#> #   `Lower house abstentions` <int>, `Upper house yes` <int>, `Upper house No` <int>, `Upper house abstentions` <int>, `Government's position` <fct>,
#> #   `Top-tier political topics` <list>, `Second-tier political topics` <list>, `Third-tier political topics` <list>, Remarks <chr>, `File metadata` <list>, …