Title: | Tools for Plotting Canadian Choropleth Maps and Choropleth Alternatives |
---|---|
Description: | A variety of functions that make it easy to plot standard choropleth maps as well as choropleth alternatives in 'ggplot2'. |
Authors: | Andrew McCormack [aut, cre], Aaron Erlich [aut] |
Maintainer: | Andrew McCormack <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1 |
Built: | 2024-10-29 03:00:41 UTC |
Source: | https://github.com/mccormackandrew/mapcan |
A data set with geographic information for Canadian census divisions
census_divisions_2016
census_divisions_2016
A data.frame with 91430 rows and 13 variables:
Longitude
Latitude
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Uniquely identifies a census division (composed of the 2-digit province/territory unique identifier followed by the 2-digit census division code).
Group
Census division name
Census division type
Province or territory 2-letter identifier
Province Standard Geographical Classification (SGC) code.
Province name (English)
Province name (French)
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A data set with geographic information for Canadian census divisions, census boundary divisions distorted by population size, territories included
census_divisions_2016_carto
census_divisions_2016_carto
A data.frame with 57513 rows and 18 variables:
Longitude
Latitude
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Uniquely identifies a census division (composed of the 2-digit province/territory unique identifier followed by the 2-digit census division code).
Group
Census division name
Census division type
Province Standard Geographical Classification (SGC) code.
Population of census division in 2016
Population density (individuals per square kilometer) in 2016
Land area of census division
Population of census division in 2011
Province or territory 2-letter identifier
Province name (English)
Province name (French)
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A data set with geographic information for Canadian census divisions, census boundary divisions distorted by population size, territories excluded
census_divisions_2016_noterr_carto
census_divisions_2016_noterr_carto
A data.frame with 35410 rows and 18 variables:
Longitude
Latitude
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Uniquely identifies a census division (composed of the 2-digit province/territory unique identifier followed by the 2-digit census division code).
Group
Census division name
Census division type
Province Standard Geographical Classification (SGC) code.
Population of census division in 2016
Population density (individuals per square kilometer) in 2016
Land area of census division
Population of census division in 2011
Province or territory 2-letter identifier
Province name (English)
Province name (French)
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A data set with population data at the census level for 2011 and 2016
census_pop2016
census_pop2016
A data.frame with 293 rows and 11 variables:
Uniquely identifies a census division (composed of the 2-digit province/territory unique identifier followed by the 2-digit census division code).
Census division name
Census division type
Province Standard Geographical Classification (SGC) code.
Province or territory name (English).
2016 Population of Province
Population density (individuals per square kilometer) in 2016
Land area of census division
2011 Population of Province
Province or territory 2-letter identifier
Province or territory name (French).
https://www12.statcan.gc.ca/census-recensement/2016/dp-pd/hlt-fst/pd-pl/comprehensive.cfm, (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A data set with information on Canadian federal election results, dating back to 1997
federal_election_results
federal_election_results
A data.frame with 37111 rows and 12 variables:
Federal electoral district name in English.
Federal electoral district name in French.
Uniquely identifies a federal electoral district (composed of the 2-digit province/territory unique identifier followed by the 3-digit federal electoral district code).
Province or territory name (English and French).
Population of federal riding.
Voter turnout
Name of winning candidate
Year of election (1997, 2000, 2004, 2006, 2008, 2011, and 2015 election included.)
Winning party in riding
Province or territory 2-letter identifier
Province or territory name (French).
Province or territory name (English).
Province Standard Geographical Classification (SGC) code.
http://www.elections.ca/content.aspx?section=ele&dir=pas&document=index&lang=e, (under Open Government Licence https://open.canada.ca/en/open-government-licence-canada)
A data set with coordinates for the mapcan::riding_binplot()
function.
federal_riding_bins
federal_riding_bins
A data.frame with 944 rows and 8 variables:
y-axis of riding bins (corresponds to longitude)
x-axis of riding bins (corresponds to latitude)
Province or territory 2-letter identifier
Representation order. Specifies boundaries/number of seats for a given election (e.g. the 2015 election used the 2013 representation order, with 338 seats).
Province or territory name (French).
Province or territory name (English).
Province Standard Geographical Classification (SGC) code.
Uniquely identifies a federal electoral district (composed of the 2-digit province/territory unique identifier followed by the 3-digit federal electoral district code).
A data set with coordinates for the mapcan::riding_binplot()
function.
federal_riding_hexagons
federal_riding_hexagons
A data.frame with 6629 rows and 15 variables:
y-axis of riding hexagons
x-axis of riding hexagons
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Group
Representation order. Specifies boundaries/seats for a given election (e.g. the 2015 election used the 2013 representation order, with 338 seats).
Province or territory name (French).
Province or territory name (English).
Province Standard Geographical Classification (SGC) code.
Uniquely identifies a federal electoral district (composed of the 2-digit province/territory unique identifier followed by the 3-digit federal electoral district code).
A data set with geographic information for Canadian federal ridings (2013 representation order)
federal_ridings
federal_ridings
A data.frame with 46830 rows and 15 variables:
Longitude
Latitude
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Uniquely identifies a federal electoral district (composed of the 2-digit province/territory unique identifier followed by the 3-digit federal electoral district code).
Group
Federal electoral district name in English.
Federal electoral district name in French.
Province Standard Geographical Classification (SGC) code
Province name (English)
Province name (French)
Province or territory 2-letter identifier
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm, (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A function that returns a data frame with map data, for use in ggplot.
mapcan(boundaries, type, province = all, territories = TRUE)
mapcan(boundaries, type, province = all, territories = TRUE)
boundaries |
Unquoted expression specifying boundary divisions. Options are |
type |
Unquoted expression specifying type of map. Options are |
province |
An unquoted expression specifying province to plot. Acceptable input is French or English province names, or two-letter provincial abbreviations. Default is to plot all provinces. |
territories |
A logical value indicating whether or not to include territories in the the returned data frame,
default is |
mapcan(boundaries = census, type = standard)
mapcan(boundaries = census, type = standard)
A data set with annual information on provincial and territorial populations dating back to 1971.
province_pop_annual
province_pop_annual
A data.frame with 638 rows and 3 variables:
English name of province
Population of province
Year
A data set with geographic information for Canadian provinces and territories, boundary divisions distorted by population size. Territories excluded.
provinces_noterr_carto
provinces_noterr_carto
A data.frame with 16797 rows and 11 variables:
Longitude
Latitude
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Province or territory name (English).
Group
2016 Population of Province
Province or territory 2-letter identifier
Province or territory name (French).
Province Standard Geographical Classification (SGC) code
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm, (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A data set with geographic information for Canadian provinces and territories
provinces_territories
provinces_territories
A data.frame with 37111 rows and 10 variables:
Longitude
Latitude
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Province Standard Geographical Classification (SGC) code
Group
Province or territory name (English).
Province or territory name (French).
Province or territory 2-letter identifier
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm, (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A data set with geographic information for Canadian provinces and territories, boundary divisions distorted by population size. Territories included.
provinces_territories_carto
provinces_territories_carto
A data.frame with 40064 rows and 12 variables:
Longitude
Latitude
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Province or territory name (English).
Group
2016 Population of Province
Province or territory 2-letter identifier
Province or territory name (French).
Province Standard Geographical Classification (SGC) code
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm, (under Statistics Canada Open Licence https://www.statcan.gc.ca/eng/reference/licence)
A data set with geographic information for Quebec provincial ridings
quebec_prov_ridings2018
quebec_prov_ridings2018
A data.frame with 23995 rows and 11 variables:
y-axis of riding hexagons
x-axis of riding hexagons
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Uniquely identifies a provincial electoral district
Group
Riding name (lowercase)
Riding name (uppercase)
Longitude for riding centroids (useful for labeling)
Latitude for riding centroids (useful for labeling)
A data set with information on 2018 Quebec provincial election results
quebec_provincial_results
quebec_provincial_results
A data.frame with 125 rows and 6 variables:
Winning party of riding.
Percentage of vote won by winning candidate.
Uniquely identifies a provincial electoral district
Riding name (lowercase)
Riding name (uppercase)
A data set with coordinates for the mapcan::riding_binplot()
function.
quebec_riding_bins
quebec_riding_bins
A data.frame with 125 rows and 6 variables:
y-axis of riding bins (corresponds to longitude)
x-axis of riding bins (corresponds to latitude)
Riding code
Region
Simplified riding name
Riding name
A data set with coordinates for the mapcan::riding_binplot()
function.
quebec_riding_hexagons
quebec_riding_hexagons
A data.frame with 6629 rows and 15 variables:
y-axis of riding hexagons
x-axis of riding hexagons
Order of layers
Polygon hole (TRUE or FALSE)
Piece
Group
y-axis of riding hexagon center
x-axis of riding hexagon center
Region
Simplified riding name
Riding name
Riding code
A function that returns a data frame with map data, for use in ggplot.
riding_binplot(riding_data, riding_col = riding_code, value_col, continuous = TRUE, arrange = FALSE, riding_border_col = "white", year = 2015, riding_border_size = 1, provincial = FALSE, shape = "square", province, legend_name = "default")
riding_binplot(riding_data, riding_col = riding_code, value_col, continuous = TRUE, arrange = FALSE, riding_border_col = "white", year = 2015, riding_border_size = 1, provincial = FALSE, shape = "square", province, legend_name = "default")
riding_data |
A dataframe with a continuous or categorical riding-level characteristic and a riding code variable. |
riding_col |
An unquoted character expression specifying the riding code variable from the dataframe
provided in |
value_col |
An unquoted character expression specifying the column or categorical riding level characteristic you would like to visualize. |
continuous |
logical. Specify as |
arrange |
logical. Specify as |
riding_border_col |
To ensure the appearance of stand alone tiles, set 'riding_border_col'
to be the same as the background colour of the plot. Default is |
year |
Election year. Options are |
riding_border_size |
Change the size of tiles. Larger values make smaller tiles. Default is |
provincial |
logical. Specify as FALSE for provincial (not federal) ridings of a single province.
If |
shape |
Unquoted character expression specifying shape of tiles. Options are square and hexagon, default is square. |
province |
An unquoted character expression specifying the 2-letter provincial abbreviation of the province for which provincial electoral boundaries are desired. (Note: this argument is still in development, only Quebec provincial boundaries are available at the moment.) |
legend_name |
Quoted chacter expression specifying the title of the legend. The variable name will be used as a default if no value is supplied. |
election_2015 <- federal_election_results[federal_election_results$election_year == 2015, ] riding_binplot(riding_data = election_2015, riding_col = riding_code, value_col = party, continuous = FALSE, arrange = TRUE)
election_2015 <- federal_election_results[federal_election_results$election_year == 2015, ] riding_binplot(riding_data = election_2015, riding_col = riding_code, value_col = party, continuous = FALSE, arrange = TRUE)
A data set with information on Canadian federal election results, dating back to 1997
riding_info
riding_info
A data.frame with 37111 rows and 12 variables:
Winning party in riding
Riding code
Population of riding in 2011
Population of riding in 2016
http://www.elections.ca/content.aspx?section=ele&dir=pas&document=index&lang=e, (under Open Government Licence https://open.canada.ca/en/open-government-licence-canada)
A ggplot theme that removes unnecessary components of map plots. Builds on theme_bw()
.
theme_mapcan(legend_position = "bottom", base_size = 12, base_family = "")
theme_mapcan(legend_position = "bottom", base_size = 12, base_family = "")
legend_position |
Position of legend, default is "bottom" |
base_size |
Base font size (default is 12) |
base_family |
Base font family |