Title: | Australian Federal Election Results (2004-2022) |
---|---|
Description: | Retrieve Australian Federal Election results for House of Representatives and Senate, from 2004 onwards. |
Authors: | Carlos Yáñez Santibáñez [aut, cre], Craig Alexander [ths], Kyle Walker [cph], Australian Electoral Commission [cph] |
Maintainer: | Carlos Yáñez Santibáñez <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1.0004 |
Built: | 2025-02-21 04:45:43 UTC |
Source: | https://github.com/carlosyanez/auspol |
Helper function generate colour palette
auspol_theme( p, type = c("colour", "fill"), extra_colours = NULL, extra_values = NULL, coord_flip = FALSE, palette = NULL, legend_pos = "none" )
auspol_theme( p, type = c("colour", "fill"), extra_colours = NULL, extra_values = NULL, coord_flip = FALSE, palette = NULL, legend_pos = "none" )
p |
ggplot object |
type |
type of scales: c("colour","fill) |
extra_colours |
named vector additional colour (hex) values |
extra_values |
vector with all unique combinations (to assign each a colour) |
coord_flip |
whether to flip coordinate axes |
palette |
additional colour palette for unnamed parties |
legend_pos |
legend position |
ggplot object
Helper function to update/download data
data_delete(file = NULL)
data_delete(file = NULL)
file |
to delete - defaults to all of them |
nothing
Helper function to update/download data
data_import(file)
data_import(file)
file |
file to import to the cache |
nothing
Helper function to update/download data
data_info()
data_info()
nothing
Helper function to update/download data
data_update(file = NULL)
data_update(file = NULL)
file |
vectors with file name from repository. By default, downloads all files |
nothing
Helper function to find cache folder
find_cache()
find_cache()
nothing
Bar chart, customised for this package.
geom_auspol_bar(include_labels = TRUE, reference_line = NULL, nudge_x = 4, ...)
geom_auspol_bar(include_labels = TRUE, reference_line = NULL, nudge_x = 4, ...)
include_labels |
Whether to include numeric labels (TRUE by default) |
reference_line |
Value for reference line. If left empty, no line is added. |
nudge_x |
distance between label and bar |
... |
parameters for ggplot2 functions. Label parameters (geom_text_repel()) prefixed with "labels." Reference line parameters (geom_vline()) prefixed with "ref_line." |
Line chart, customised for this package.
geom_auspol_line(include_labels = TRUE, ...)
geom_auspol_line(include_labels = TRUE, ...)
include_labels |
Whether to include numeric labels (TRUE by default) |
... |
parameters for ggplot2 functions. Label parameters (geom_text_repel()) prefixed with "labels." |
Lollipop or bar chart, custommised for this package.
geom_auspol_lollipop(format = "lollipop", include_labels = TRUE, ...)
geom_auspol_lollipop(format = "lollipop", include_labels = TRUE, ...)
format |
Output format : "lollipop" (default) or "bar". |
include_labels |
Whether to include numeric labels (TRUE by default) |
... |
parameters for ggplot2 geom_segment() (segmnet.prefix), geom_point(), geom_col() and geom_text() (labels. prefix). |
Get flow from primary vote to finalists, for an division on a given election
get_house_2PF(division, year, aggregation = FALSE)
get_house_2PF(division, year, aggregation = FALSE)
division |
character vector with division names. When left blank, returns all division. |
year |
number vector with election years. When left blank, returns all years. |
aggregation |
Whether to present division totals (defaults to FALSE) |
dataframe with list of elected MPs
## Not run: # get primary to finalist flow of preferences for Jagajaga in the 2013 election get_house_2PF(division="Jagajaga",year=2013,aggregation = TRUE) ## End(Not run)
## Not run: # get primary to finalist flow of preferences for Jagajaga in the 2013 election get_house_2PF(division="Jagajaga",year=2013,aggregation = TRUE) ## End(Not run)
Get 2-party preferred party summary (Coalition vs ALP), as calculated by the AEC.
get_house_2PP( division = NULL, year = NULL, state_abb = NULL, aggregation = FALSE )
get_house_2PP( division = NULL, year = NULL, state_abb = NULL, aggregation = FALSE )
division |
character vector with division names. When left blank, returns all division. |
year |
number vector with election years. When left blank, returns all years. |
state_abb |
vector with state/territory acronym (e.g. NSW,VIC,QLD,etc.) |
aggregation |
Whether to present division totals (defaults to FALSE) |
dataframe with list of elected MPs
## Not run: get_house_2PP(division = "Indi", year=2016, aggregation = TRUE) ## End(Not run)
## Not run: get_house_2PP(division = "Indi", year=2016, aggregation = TRUE) ## End(Not run)
Retrieve list of elected MPs, filterable by division and year
get_house_MPs(division = NULL, year = NULL) get_MPs(division = NULL, year = NULL)
get_house_MPs(division = NULL, year = NULL) get_MPs(division = NULL, year = NULL)
division |
character vector with division names. When left blank, returns all division. |
year |
number vector with election years. When left blank, returns all years. |
data frame with list of elected MPs
## Not run: # Elected MPs in Melbourne and Cooper, 2019 and 2022 get_house_MPs(division = c("Melbourne","Cooper"), year = c(2019,2022)) ## End(Not run)
## Not run: # Elected MPs in Melbourne and Cooper, 2019 and 2022 get_house_MPs(division = c("Melbourne","Cooper"), year = c(2019,2022)) ## End(Not run)
Retrieves preference flow, filterable by election and year. Results can be presented by polling place - as retrived from the AEC - or aggregated by electoral division.
get_house_preferences( division, year, polling_places = NULL, aggregation = FALSE ) get_preferences(division, year, polling_places = NULL, aggregation = FALSE)
get_house_preferences( division, year, polling_places = NULL, aggregation = FALSE ) get_preferences(division, year, polling_places = NULL, aggregation = FALSE)
division |
vector with division names |
year |
vector with election years |
polling_places |
list of polling places |
aggregation |
whether to aggregate by division |
dataframe with list of elected MPs
## Not run: # basic use get_house_preferences("Wills",2019) |> head(10) # aggregated version get_house_preferences("Wills",2019,aggregation = TRUE) # filtered by polling place get_house_preferences("Wills",2019, polling_places=c("ABSENT")) |> head(10) ## End(Not run)
## Not run: # basic use get_house_preferences("Wills",2019) |> head(10) # aggregated version get_house_preferences("Wills",2019,aggregation = TRUE) # filtered by polling place get_house_preferences("Wills",2019, polling_places=c("ABSENT")) |> head(10) ## End(Not run)
Get primary vote for one or more divisions, for one or more elections. Data can be filtered by state, political party of polling locations. Results can be presented by polling station or aggregated by division.
get_house_primary_vote( division = NULL, year = NULL, state_abb = NULL, party_abb = NULL, aggregation = FALSE, polling_places = NULL )
get_house_primary_vote( division = NULL, year = NULL, state_abb = NULL, party_abb = NULL, aggregation = FALSE, polling_places = NULL )
division |
character vector with division names. When left blank, returns all division. |
year |
number vector with election years. When left blank, returns all years. |
state_abb |
vector with state/territory acronym (e.g. NSW,VIC,QLD,etc.) |
party_abb |
vector with party abbreviation (e.g. ALP,LIB,NP,GRN,etc.) |
aggregation |
Whether to present division totals (defaults to FALSE) |
polling_places |
vector with regex for polling places |
sf object with selected polygons
## Not run: # Primary vote in Brisbane, 2022 election get_house_primary_vote(division="Brisbane",year=2022) # Primary vote in Perth and Brisbane in 2019 and 2022 (aggregated) get_house_primary_vote(division=c("Brisbane","Perth"),year=c(2019,2022),aggregation = TRUE) # Primary vote for Greens candidates in Tasmania and the Northern Territory, 2019 get_house_primary_vote(state=c("TAS","NT"),year=2019,aggregation = TRUE, party_abb=c("GRN")) ## End(Not run)
## Not run: # Primary vote in Brisbane, 2022 election get_house_primary_vote(division="Brisbane",year=2022) # Primary vote in Perth and Brisbane in 2019 and 2022 (aggregated) get_house_primary_vote(division=c("Brisbane","Perth"),year=c(2019,2022),aggregation = TRUE) # Primary vote for Greens candidates in Tasmania and the Northern Territory, 2019 get_house_primary_vote(state=c("TAS","NT"),year=2019,aggregation = TRUE, party_abb=c("GRN")) ## End(Not run)
Retrieve election turnout, filterable by division and year
get_house_turnout(division = NULL, year = NULL)
get_house_turnout(division = NULL, year = NULL)
division |
character vector with division names. When left blank, returns all division. |
year |
number vector with election years. When left blank, returns all years. |
data frame turnout numbers
## Not run: # Turnout in Riverina get_house_turnout(division="Riverina",yeat) ## End(Not run)
## Not run: # Turnout in Riverina get_house_turnout(division="Riverina",yeat) ## End(Not run)
Plot representing flow of preferences from first preferences to candidates in last round. Can be present as alluvial plot or bar chart, showing votes count or percentages.
house_2PF_plot( division, year, var = "Percent", extra_colours = NULL, plot_format = "bar", include_data = FALSE, individualise_IND = TRUE )
house_2PF_plot( division, year, var = "Percent", extra_colours = NULL, plot_format = "bar", include_data = FALSE, individualise_IND = TRUE )
division |
Electoral division |
year |
Election year |
var |
Variable to be plotted "Percent" (default) or "Transfer Count" |
extra_colours |
manual mapping of colours for each party, as a named vector. |
plot_format |
Whether to plot alluvial chart ("alluvial") or a bar chart ("bar", default). |
include_data |
If set to TRUE, data will be included under <<output_var>>$source_data (defaults to FALSE) |
individualise_IND |
If set to TRUE, party abbreviations for each independent candidate will be changed from "IND" to "IND-<<candidate's surname>>", effectively separating them in party aggregations. |
preference flow, ggplot2 object
## Not run: # Preference flow for Burt, 2022 house_2PF_plot("Burt",2022,plot_format = "alluvial") # Preference flow for Warringah 2022, house_2PF_plot("Spence",2013,plot_format = "bar") ## End(Not run)
## Not run: # Preference flow for Burt, 2022 house_2PF_plot("Burt",2022,plot_format = "alluvial") # Preference flow for Warringah 2022, house_2PF_plot("Spence",2013,plot_format = "bar") ## End(Not run)
Plot with two-party preferred values for one of more divisions, for a given year Can be present as alluvial plot or bar chart, showing votes count or percentages.
house_2PP_comparison_plot( division = NULL, year, state = NULL, var = "Percentage", include_data = TRUE )
house_2PP_comparison_plot( division = NULL, year, state = NULL, var = "Percentage", include_data = TRUE )
division |
Electoral division |
year |
Election year |
state |
If division is left null, use this to select all divisions in one of more states. |
var |
Variable to be plotted "Percentage" (default) or "Votes" |
include_data |
If set to TRUE, data will be included under <<output_var>>$source_data (defaults to FALSE) |
ggplot2 object
## Not run: # Two party preferred plot for Victoria, 2022 house_2PP_comparison_plot(year=2022,state="VIC") ## End(Not run)
## Not run: # Two party preferred plot for Victoria, 2022 house_2PP_comparison_plot(year=2022,state="VIC") ## End(Not run)
Plot with two-party preferred values for one of more divisions, for a given year Can be present as alluvial plot or bar chart, showing votes count or percentages.
house_2PP_historical_plot( division, year = NULL, var = "Percentage", include_labels = TRUE, include_data = TRUE )
house_2PP_historical_plot( division, year = NULL, var = "Percentage", include_labels = TRUE, include_data = TRUE )
division |
Electoral division |
year |
Election year |
var |
Variable to be plotted "Percentage" (default) or "Votes" |
include_labels |
If set to TRUE, the plot will include each value. |
include_data |
If set to TRUE, data will be included under <<output_var>>$source_data (defaults to FALSE) |
ggplot2 object
## Not run: # Plot historical 2PP for Aston house_2PP_historical_plot(division="Aston") ## End(Not run)
## Not run: # Plot historical 2PP for Aston house_2PP_historical_plot(division="Aston") ## End(Not run)
retrieves data containing preferential voting rounds for a division in a particular election (as published by the AEC). Can be filtered by polling place (including special modes of voting) or it can be presented as an aggregate per division.
house_preference_flow_data( division, year, individualise_IND = TRUE, exclude_parties = NULL, exclude_rounds = 0 )
house_preference_flow_data( division, year, individualise_IND = TRUE, exclude_parties = NULL, exclude_rounds = 0 )
division |
division |
year |
election year |
individualise_IND |
If set to TRUE, party abbreviations for each independent candidate will be changed from "IND" to "IND-<<candidate's surname>>", effectively separating them in party aggregations. |
exclude_parties |
vector with party acronyms to exclude from plot |
exclude_rounds |
If parties are excluded, include vector indicating from which rounds should them be excluded |
list with data frames with results for each round
## Not run: #get preferences for Wills, 2019 get_house_preferences("Wills",2019) show results for absent votes only get_house_preferences("Wills",2019, polling_places=c("ABSENT"),aggregation = FALSE) ## End(Not run)
## Not run: #get preferences for Wills, 2019 get_house_preferences("Wills",2019) show results for absent votes only get_house_preferences("Wills",2019, polling_places=c("ABSENT"),aggregation = FALSE) ## End(Not run)
Plot flow of preferences in a division as an alluvial plot.
house_preference_flow_plot( division, year, var = "Percent", exclude_parties = NULL, merge_parties = NULL, extra_colours = NULL, include_data = FALSE )
house_preference_flow_plot( division, year, var = "Percent", exclude_parties = NULL, merge_parties = NULL, extra_colours = NULL, include_data = FALSE )
division |
Electoral division |
year |
Election year |
var |
Variable to be plotted "Percent" (default) or "Preference Count" |
exclude_parties |
vector with party acronyms to exclude from plot |
merge_parties |
list of parties to merge in one line following, the format list(NEWCODE=c(code1,code2,etc.)) |
extra_colours |
manual mapping of colours for each party, as a named vector. |
include_data |
If set to TRUE, output of primary_vote_summary(), will be included under <<output_var>>$source_data (defaults to FALSE) |
preference flow, ggplot2 object
## Not run: # Preference flow for Wills, 2019 house_preference_flow_plot(division = "Wills",year=2019) # Preference flow for Warringah 2022, # excluding two finalists from round 1, # independent candidate in teal. house_preference_flow_plot(division = "Warringah",year=2022, ## End(Not run)
## Not run: # Preference flow for Wills, 2019 house_preference_flow_plot(division = "Wills",year=2019) # Preference flow for Warringah 2022, # excluding two finalists from round 1, # independent candidate in teal. house_preference_flow_plot(division = "Warringah",year=2022, ## End(Not run)
Line chart with historial changes for a division, group of candidates in a party, selected parties, etc.
house_primary_comparison_plot( division = NULL, year = NULL, state = NULL, label = "Candidate", plotted_variable = "Percentage", sort_by_value = TRUE, extra_colours = NULL, plot_format = "lollipop", include_labels = FALSE, hor_nudge = 5, parties = NULL, parties_year = NULL, merge_parties = NULL, include_others = FALSE, include_informal = FALSE, individualise_IND = TRUE, include_data = TRUE, data = NULL )
house_primary_comparison_plot( division = NULL, year = NULL, state = NULL, label = "Candidate", plotted_variable = "Percentage", sort_by_value = TRUE, extra_colours = NULL, plot_format = "lollipop", include_labels = FALSE, hor_nudge = 5, parties = NULL, parties_year = NULL, merge_parties = NULL, include_others = FALSE, include_informal = FALSE, individualise_IND = TRUE, include_data = TRUE, data = NULL )
division |
Name of ONE electoral division |
year |
numeric vector with election years (from 2004), defaults to all. |
state |
Code for one state |
label |
How to label the results, either by Candidate Name ("Name",default), Party Name ("PartyNm") or Party abbreviation ("PartyAb") |
plotted_variable |
Variable to plot, out of "OrdinaryVotes", "Percentage" (default) and Percentage_with_Informal |
sort_by_value |
Whether to sort results by descending order (TRUE by default) |
extra_colours |
manual mapping of colours for each party, as a named vector. |
plot_format |
Whether to plot lollipop chart ("lollipop", default) or a bar chart. |
include_labels |
If set to TRUE, the plot will include each value. |
hor_nudge |
if labels are included, separation from chart/dot |
parties |
which parties to include in the summary. All (default), a vector of strings with the party acronyms (see list_parties()), or a number indicating the top n parties from a certain year. |
parties_year |
If parties has is NULL or a number, this indicates if the selection needs to be from a certain year (.e.g only select the historical data for the three top parties in 2012) |
merge_parties |
list of parties to merge in one line following, the format list(NEWCODE=c(code1,code2,etc.)) |
include_others |
Boolean used along parties to included the remaining votes in one "Other" category. |
include_informal |
Boolean to add informal votes in addition to the party selection. Informal votes will be included if no parties are selected, or the top n parties are selected, and it happens to be in the top n - even if this flag is set to false. |
individualise_IND |
If set to TRUE, party abbreviations for each independent candidate will be changed from "IND" to "IND-<<candidate's surname>>", effectively separating them in party aggregations. |
include_data |
If set to TRUE, output of house_primary_vote_summary(), will be included under <<output_var>>$source_data (defaults to FALSE) |
data |
Alternative, instead of providing a parameters, it is possible to provide the data frame with the data to plot, following the format from the output of house_primary_vote_summary(). |
ggplot2 object
## Not run: # Compare primary voting in Kooyong in 2022, lollipop chart (default) house_primary_comparison_plot(division = "Kooyong", year=2022, individualise_IND = TRUE) # Liberal Primary vote in Tasmania in 2022, bar chart house_primary_comparison_plot(state="TAS", year=2022, parties=c("LP"), plot_format = "bar") ## End(Not run)
## Not run: # Compare primary voting in Kooyong in 2022, lollipop chart (default) house_primary_comparison_plot(division = "Kooyong", year=2022, individualise_IND = TRUE) # Liberal Primary vote in Tasmania in 2022, bar chart house_primary_comparison_plot(state="TAS", year=2022, parties=c("LP"), plot_format = "bar") ## End(Not run)
Plot historical primary vote results for a division or group of divisions, being able to select and aggregate political parties. Can plot either percentages or absolute number of ordinary votes.
house_primary_historic_plot( division = NULL, plotted_variable = "Percentage", parties = NULL, parties_year = NULL, merge_parties = NULL, include_others = FALSE, include_informal = FALSE, individualise_IND = FALSE, extra_colours = NULL, include_labels = FALSE, year = NULL, include_data = FALSE, include_text_tooltip = FALSE, data = NULL )
house_primary_historic_plot( division = NULL, plotted_variable = "Percentage", parties = NULL, parties_year = NULL, merge_parties = NULL, include_others = FALSE, include_informal = FALSE, individualise_IND = FALSE, extra_colours = NULL, include_labels = FALSE, year = NULL, include_data = FALSE, include_text_tooltip = FALSE, data = NULL )
division |
named vector with division names |
plotted_variable |
Variable to plot, out of "OrdinaryVotes", "Percentage" (default) and Percentage_with_Informal |
parties |
which parties to include in the summary. All (default), a vector of strings with the party acronyms (see list_parties()), or a number indicating the top n parties from a certain year. |
parties_year |
If parties has is NULL or a number, this indicates if the selection needs to be from a certain year (.e.g only select the historical data for the three top parties in 2012). |
merge_parties |
list of parties to merge in one line following, the format list(NEWCODE=c(code1,code2,etc.)) |
include_others |
Boolean used along parties to included the remaining votes in one "Other" category. |
include_informal |
Boolean to add informal votes in addition to the party selection. Informal votes will be included if no parties are selected, or the top n parties are selected, and it happens to be in the top n - even if this flag is set to false. |
individualise_IND |
If set to TRUE, party abbreviations for each independent candidate will be changed from "IND" to "IND-<<candidate's surname>>", effectively separating them in party aggregations. |
extra_colours |
manual mapping of colours for each party, as a named vector. |
include_labels |
If set to TRUE, the plot will include each value. |
year |
numeric vector with election years (from 2004), defaults to all. |
include_data |
If set to TRUE, output of house_primary_vote_summary(), will be included under <<output_var>>$source_data (defaults to FALSE) |
include_text_tooltip |
Flag to include tooltip for plotly mapped as text in ggplot |
data |
Alternative, instead of providing a parameters, it is possible to provide the data frame with the data to plot, folowing the format from the output of house_primary_vote_summary(). |
ggplot2 object
## Not run: # Plot historic primary voting in Canberra, top 3 parties house_primary_historic_plot("Canberra", parties =3, ## End(Not run)
## Not run: # Plot historic primary voting in Canberra, top 3 parties house_primary_historic_plot("Canberra", parties =3, ## End(Not run)
Helper function to download data
house_primary_vote_summary( division = NULL, state = NULL, year = NULL, parties = NULL, parties_year = NULL, include_others = FALSE, merge_parties = NULL, include_informal = FALSE, include_names = TRUE, individualise_IND = FALSE, wide_format = NULL )
house_primary_vote_summary( division = NULL, state = NULL, year = NULL, parties = NULL, parties_year = NULL, include_others = FALSE, merge_parties = NULL, include_informal = FALSE, include_names = TRUE, individualise_IND = FALSE, wide_format = NULL )
division |
vector with names of electoral divisions (e.g. "Banks", "Wills","Indi") |
state |
if divisions are not provide, provide a vector with state initials e.g. c("NT","TAS") |
year |
numeric vector with election years (from 2004), defaults to all. |
parties |
which parties to include in the summary. All (default), a vector of strings with the party acronyms (see list_parties()), or a number indicating the top n parties from a certain year. |
parties_year |
If parties has is NULL or a number, this indicates if the selection needs to be from a certain year (.e.g only select the historical data for the three top parties in 2012) |
include_others |
Boolean used along parties to included the remaining votes in one "Other" category. |
merge_parties |
list of parties to merge in one line following, the format list(NEWCODE=c(code1,code2,etc.)) |
include_informal |
Boolean to add informal votes in addition to the party selection. Informal votes will be included if no parties are selected, or the top n parties are selected, and it happens to be in the top n - even if this flag is set to false. |
include_names |
whether to include the candidates name and surname in the extract (TRUE by default). |
individualise_IND |
If set to TRUE, party abbreviations for each independent candidate will be changed from "IND" to "IND-<<candidate's surname>>", effectively separating them in party aggregations. |
wide_format |
Whether to present the result in long format, like the AEC's source, or a year-by-year summary. Options include NULL (no summarisation, default), "OrdinaryVotes" (absolute numbers), "Percentage_with_Informal" and "Percentage" (which is the percentage counted on elections). |
dataframe
## Not run: # Get primary for Kooyong in 2022 house_primary_vote(division="Kooyong",year=2022) # Get historic primary for Liberals and Labor in Kooyong house_primary_vote(division="Kooyong",parties=c("LP","ALP") #Get primary vote for all National candidates in WA, 2022 house_primary_vote(state="WA",year=2022,parties=c(NP)) ## End(Not run)
## Not run: # Get primary for Kooyong in 2022 house_primary_vote(division="Kooyong",year=2022) # Get historic primary for Liberals and Labor in Kooyong house_primary_vote(division="Kooyong",parties=c("LP","ALP") #Get primary vote for all National candidates in WA, 2022 house_primary_vote(state="WA",year=2022,parties=c(NP)) ## End(Not run)
Plot seats by party across time. Parties can be filtered and grouped by coalitions.
house_results_historic( individualise_IND = FALSE, merge_parties = NULL, parties = NULL, include_others = FALSE, include_labels = TRUE, extra_colours = NULL, include_data = FALSE )
house_results_historic( individualise_IND = FALSE, merge_parties = NULL, parties = NULL, include_others = FALSE, include_labels = TRUE, extra_colours = NULL, include_data = FALSE )
individualise_IND |
If set to TRUE, party abbreviations for each independent candidate will be changed from "IND" to "IND-<<candidate's surname>>", effectively separating them in party aggregations. |
merge_parties |
list of parties to merge in one line following, the format list(NEWCODE=c(code1,code2,etc.)) |
parties |
List of political party abbreviations to filter on. If merge_parties is used, those names can be included too. |
include_others |
Boolean used along parties to included the remaining votes in one "Other" category. |
include_labels |
If set to TRUE, the plot will include each value. |
extra_colours |
manual mapping of colours for each party, as a named vector. |
include_data |
If set to TRUE, data will be included under <<output_var>>$source_data (defaults to FALSE) |
preference flow, ggplot2 object
## Not run: # Historic results, focusing showing tally for Coalition, ALP, Greens - others merged together house_results_historic(merge_parties = list(COAL=c("CLP","LP","LNP","NP")), parties =c("COAL","ALP","GRN"), include_other=TRUE)) ## End(Not run)
## Not run: # Historic results, focusing showing tally for Coalition, ALP, Greens - others merged together house_results_historic(merge_parties = list(COAL=c("CLP","LP","LNP","NP")), parties =c("COAL","ALP","GRN"), include_other=TRUE)) ## End(Not run)
Plot party totals for a given election. Can aggregate parties into groups, amongst other filters.
house_results_tally( year, individualise_IND = FALSE, merge_parties = NULL, add_majority_line = TRUE, include_labels = FALSE, extra_colours = NULL, include_data = FALSE )
house_results_tally( year, individualise_IND = FALSE, merge_parties = NULL, add_majority_line = TRUE, include_labels = FALSE, extra_colours = NULL, include_data = FALSE )
year |
Election year |
individualise_IND |
If set to TRUE, party abbreviations for each independent candidate will be changed from "IND" to "IND-<<candidate's surname>>", effectively separating them in party aggregations. |
merge_parties |
list of parties to merge in one line following, the format list(NEWCODE=c(code1,code2,etc.)) |
add_majority_line |
add line representing 50% +1 of the seats |
include_labels |
If set to TRUE, the plot will include each value. |
extra_colours |
manual mapping of colours for each party, as a named vector. |
include_data |
If set to TRUE, data will be included under <<output_var>>$source_data (defaults to FALSE) |
preference flow, ggplot2 object
## Not run: # Basic example house_results_tally(2013) # Coalition votes put together house_results_tally(2013, merge_parties = list(COAL=c("CLP","LP","LNP","NP"))) ## End(Not run)
## Not run: # Basic example house_results_tally(2013) # Coalition votes put together house_results_tally(2013, merge_parties = list(COAL=c("CLP","LP","LNP","NP"))) ## End(Not run)
get list of all the Australian Federal electoral divisions, being able to filter by any attribute. Covers all divisions from the 2004 Election.
list_divisions(filters = NULL)
list_divisions(filters = NULL)
filters |
(optional) list() with filters in the form list(Column="Value") |
data frame with lists of divisions
## Not run: # Get list of all divisions list_divisions() #Get list containing only Wills and Melbourne list_divisions(filters=list(DivisionNm=c("Wills","Melbourne"))) ## End(Not run)
## Not run: # Get list of all divisions list_divisions() #Get list containing only Wills and Melbourne list_divisions(filters=list(DivisionNm=c("Wills","Melbourne"))) ## End(Not run)
Lists all political parties that have participated from the 2004 Election onwards. Parties are presented as recorded by the AEC. List can be filtered by party names matching a regular expression.
list_parties(filters = NULL, party_regex = NULL)
list_parties(filters = NULL, party_regex = NULL)
filters |
(optional) list() with filters in the form list(Column="Value"). |
party_regex |
additional filter for party names, taking a regular expression. |
data frame with lists of divisions
## Not run: # Get list of all registered political parties list_parties() # # Get list of all parties whose name start with "Australia" list_parties(party_regex="^Australia") ## End(Not run)
## Not run: # Get list of all registered political parties list_parties() # # Get list of all parties whose name start with "Australia" list_parties(party_regex="^Australia") ## End(Not run)
Retrieve list of all polling station that been used from 2044 onwards. Names as recorded by the AEC. List can be filtered by state, division names and regular expressions matching their names.
list_polling_places(filters = NULL)
list_polling_places(filters = NULL)
filters |
(optional) list() with filters in the form list(Column="Value") |
data frame with lists of polling stations
## Not run: # Get list of all registered parties list_parties() # Get list of polling places in the division of Hasluck list_parties(list) ## End(Not run)
## Not run: # Get list of all registered parties list_parties() # Get list of polling places in the division of Hasluck list_parties(list) ## End(Not run)
Very simple function listing the election years included in this package.
list_years()
list_years()
vector with years
## Not run: # Get list of all divisions list_years() ## End(Not run)
## Not run: # Get list of all divisions list_years() ## End(Not run)
Helper function generate colour palette
manage_colours(extra_colours = NULL, extra_values = NULL, palette = NULL)
manage_colours(extra_colours = NULL, extra_values = NULL, palette = NULL)
extra_colours |
named vector additional colour (hex) values |
extra_values |
vector with all unique combinations (to assign each a colour) |
palette |
palette to replace brewer.pal |
named vector with colours
Named vector with common party colours, with option to add custom/additional values
party_colours(extra = NULL)
party_colours(extra = NULL)
extra |
named vector additional colour (hex) values |
named vector