requireNamespace("tibble")
library(electionca)

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  dpi = 300
)

electionca

Lifecycle: experimental Travis build status

The goal of electionca is to provide Canadian (general) election data in an easily accessible format for R users. It is based on the Library of Parliament's ParlInfo site, but also includes geography for elections since 2003 (2003, 2013 and 2015). Approximate geography is derived for historical ridings based on riding associations noted by the Library of Parliament.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("paleolimbot/electionca")

If you can load the package, you're all set!

library(electionca)

Example

This package contains geographic information about ridings (ridings), results from each riding for each general election (results), and low-resolution boundaries, where these are known (2006-present). It contains convenience functions to plot election results in bar, cartogram, and map format:

plot_votes()
plot_seats()
plot_election()
plot_election_map()

The easiest way to access the data in this package is through the election_results() function, which modifies the raw data slightly to provide the data that you probably want to work with:

election_results()

If you're looking to do a more comprehensive analysis, you can access the raw data using results, ridings, and boundaries.

results
ridings
boundaries

For examples of how to use the raw data to create the plots returned by plot_election_map() and plot_election(), see vignette("plot_election", package = "electionca").



paleolimbot/electionca documentation built on Jan. 23, 2020, 4:36 p.m.