Fetches election results in the format that you probably want for plotting. For more complex operations, use joins of results, ridings, and/or boundaries. Note that in elections before 1968 there was more than one MP elected from several ridings.

election_results(
  years = election_years(),
  provinces = election_provinces(),
  results = c("Elected", "Defeated")
)

Arguments

years

One or more election_years() to include in the data

provinces

One or more election_provinces() (or terretories) include in the data. The order of provinces is kept in the data by making the province variable a factor.

results

One or both of "Elected" and/or "Defeated" to include in the data

Value

A tibble::tibble() of a join between results and ridings.

Examples

election_results( years = 2015:2019, provinces = c("Nova Scotia", "New Brunswick") )
#> # A tibble: 225 x 11 #> election_date riding name party votes result person_id province riding_label #> <date> <chr> <chr> <chr> <dbl> <chr> <dbl> <fct> <chr> #> 1 2015-10-19 NB/19… Serg… Libe… 25845 Elect… 18458 New Bru… Acadie--Bat… #> 2 2015-10-19 NB/19… Jaso… New … 20079 Defea… NA New Bru… Acadie--Bat… #> 3 2015-10-19 NB/19… Riba… Cons… 3852 Defea… NA New Bru… Acadie--Bat… #> 4 2015-10-19 NB/19… Domi… Gree… 1187 Defea… NA New Bru… Acadie--Bat… #> 5 2015-10-19 NB/19… Matt… Libe… 23016 Elect… 18459 New Bru… Fredericton #> 6 2015-10-19 NB/19… Keit… Cons… 13280 Defea… 17264 New Bru… Fredericton #> 7 2015-10-19 NB/19… Mary… Gree… 5804 Defea… NA New Bru… Fredericton #> 8 2015-10-19 NB/19… Shar… New … 4622 Defea… NA New Bru… Fredericton #> 9 2015-10-19 NB/19… René… Libe… 20778 Elect… 18461 New Bru… Madawaska--… #> 10 2015-10-19 NB/19… Rosa… New … 9670 Defea… NA New Bru… Madawaska--… #> # … with 215 more rows, and 2 more variables: riding_id <dbl>, #> # election_year <dbl>