View source: R/clean_party_names.R
clean_party_names | R Documentation |
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.
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
)
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. |
A vector of party names.
clean_party_names(c("Labour", "Lab", "Lib", "Conservatives", "Tories"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.