Learn R Programming

hansard (version 0.4.6)

election_results: Imports data on general election and by-election results

Description

Imports data on general election and by-election results

Usage

election_results(ID = NULL, calculate_percent = FALSE,
  constit_details = FALSE, extra_args = NULL, tidy = TRUE,
  tidy_style = "snake_case")

Arguments

ID

Accepts an ID for a general or by-election from the 2010 general election onwards, and returns the results. If NULL, returns all available election results. Defaults to NULL.

calculate_percent

If TRUE, calculates the turnout percentage for each constituency in the tibble and the majority of the winning candidate to one decimal place, and includes this information in the tibble in additional columns labelled 'turnout_percentage' and 'majority_percentage'. Defaults to FALSE.

constit_details

If TRUE, returns additional details on each constituency, including its GSS (Government Statistical Service) code. Defaults to FALSE.

extra_args

Additional parameters to pass to API. Defaults to NULL.

tidy

Fix the variable names in the tibble to remove special characters and superfluous text, and converts the variable names to a consistent style. Defaults to TRUE.

tidy_style

The style to convert variable names to, if tidy = TRUE. Accepts one of 'snake_case', 'camelCase' and 'period.case'. Defaults to 'snake_case'.

Value

A tibble with the results of all general and by-elections, or of a specified general election or by-election.

Examples

Run this code
# NOT RUN {
x <- election_results(ID=382037)

# }

Run the code above in your browser using DataLab