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,889 × 69
#>    `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 670cd145c3c… NA            NA           CH                     Switze… Zug                  NA           subnational       2024-06-09 NA                Cycl…
#>  2 66fff490c3c… NA            NA           LI                     Liecht… NA                   NA           national          2024-09-22 NA                Refe…
#>  3 66ffdfe3c3c… NA            NA           CH                     Switze… Jura                 NA           subnational       2024-09-22 NA                Act …
#>  4 66f686cfc3c… NA            NA           CH                     Switze… Bern                 NA           subnational       2024-09-22 NA                Conc…
#>  5 66f68317c3c… NA            NA           CH                     Switze… Bern                 NA           subnational       2024-09-22 NA                Amen…
#>  6 66d6da9cc3c… NA            NA           CH                     Switze… Basel Landschaft     NA           subnational       2024-09-22 NA                Part…
#>  7 66cde603c3c… NA            NA           CH                     Switze… Graubünden           NA           subnational       2024-09-22 NA                New …
#>  8 66c46f86c3c… NA            NA           CH                     Switze… Schwyz               NA           subnational       2024-09-22 NA                Appr…
#>  9 66c46cf6c3c… NA            NA           CH                     Switze… Solothurn            NA           subnational       2024-09-22 NA                Appo…
#> 10 66c46c3ac3c… NA            NA           CH                     Switze… Solothurn            NA           subnational       2024-09-22 NA                Amen…
#> # ℹ 17,879 more rows
#> # ℹ abbreviated name: ¹​`ISO 3166-1 alpha-2 / ISO 3166-3 alpha-4`
#> # ℹ 58 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>, …