clean_party_names: Clean British Political Party Names

View source: R/clean_party_names.R

clean_party_namesR Documentation

Clean British Political Party Names

Description

For a majoritarian democracy, Britain has quite a few parties. Further, some of the main parties come in more than one variant (e.g. Labour & Co-op). This function takes a vector of party names, simplifies them, and then returns them to the user. It also includes some useful options to customise the output.

Usage

clean_party_names(
  x,
  party_names = list(`^con|^tor` = "Conservatives", `^lab` = "Labour", `^lib|^ld` =
    "Liberals etc.", `^snp|^scotnat|^scottishnat` = "SNP", `^pc|^plaid` = "Plaid Cymru"),
  nat = TRUE,
  drop_dk = TRUE
)

Arguments

x

A vector of party names.

party_names

A list of regular expressions to detect for each party, followed by the name to give the party. Note, the function converts all text to lower-case and removes any whitespace prior to simplification. E.g. list("^con|^tor" = "Conservative", "^lab" = "Labour).

nat

Include nationalist parties or mark them as "Other"? Defaults to TRUE and includes them by default.

drop_dk

Mark "Don't know", "Refused", etc. as missing? Defaults to TRUE.

Value

A vector of party names.

Examples

clean_party_names(c("Labour", "Lab", "Lib", "Conservatives", "Tories"))

jackobailey/britpol documentation built on Aug. 6, 2023, 2:30 a.m.