riding_binplot {mapcan} | R Documentation |
Canadian federal ridings tile plot function
Description
A function that returns a data frame with map data, for use in ggplot.
Usage
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")
Arguments
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. |
Examples
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)