| Title: | Retrieve Data from the Parliamentary Handbook of the Commonwealth of Australia |
| Version: | 1.0.1 |
| Description: | Retrieves data from the Australian Parliamentary Library's Parliamentary Handbook https://handbook.aph.gov.au/ and returns it as tidy tables: members and senators, their parliamentary and party service, ministries, shadow ministries, committees, parties, electorates, parliaments, sitting dates, elections and two candidate preferred results. Known errors in the Handbook are flagged, and can optionally be corrected from a documented errata table. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/palesl/ausPH |
| BugReports: | https://github.com/palesl/ausPH/issues |
| Encoding: | UTF-8 |
| Language: | en-AU |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Depends: | R (≥ 4.1.0) |
| Imports: | rjson, dplyr, readr |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-10-27 23:25:48 UTC; u1040068 |
| Author: | Pat Leslie |
| Maintainer: | Pat Leslie <patrick.leslie@anu.edu.au> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-12 18:50:02 UTC |
Data on two candidate preferred results since 1919
Description
Results come from a copy of the Handbook stored in the package,
supplemented with results the Handbook is missing (documented in the
Note and source columns). A supplementary result is only used where the
Handbook has none for that division and year. By default, results for any
elections the Handbook has listed since the stored copy was made are added.
The date of the stored copy is in the scraped attribute of the result,
and the date of any update in the updated attribute.
Usage
get2CP(include_byelections = FALSE, update = TRUE)
Arguments
include_byelections |
Choose to include house by-elections. If include_byelections = TRUE, by-election results are added. |
update |
if TRUE (the default), add results for elections listed in the Handbook since the stored copy was made (three requests, plus one per new election); if FALSE, use the stored copy only. |
Value
a tibble. pID links a candidate's party to getParties() where
the Handbook's party name matches a party exactly; otherwise it is NA.
Examples
get2CP(update=FALSE)
Data on committee memberships since 1902
Description
Data on committee memberships since 1902
Usage
getCommitteeMembers()
Value
a tibble. end_date is NA for current memberships.
Examples
getCommitteeMembers()
Data on elections since 1901
Description
All federal general elections, House by-elections and supplementary
elections, excluding elections for casual vacancies in the Senate. The
package stores a copy reconciled with the Handbook; by default, any
elections the Handbook has listed since are added to it. The date of the
stored copy is in the scraped attribute of the result, and the date of
any update in the updated attribute.
Usage
getElections(
chamber = c("all", "house", "senate"),
byelections = FALSE,
apply_errata = FALSE,
update = TRUE
)
Arguments
chamber |
Select from c("all","house","senate") |
byelections |
Choose to include house by-elections. If byelections = TRUE, then a list of elections with by-elections and their divisions is returned. |
apply_errata |
if TRUE, replace values listed in |
update |
if TRUE (the default), add elections listed in the Handbook since the stored copy was made (two requests); if FALSE, use the stored copy only. |
Value
a tibble. Id is the package's election identifier (used as
ElectionID in get2CP()); HandbookId is the Handbook's own
identifier, NA for elections the Handbook does not list. For elections
added by an update, FullSenateElection is NA, because the Handbook's
list of elections does not say whether an election was a double
dissolution. handbook_flag marks elections not_in_handbook and issues
listed in getErrata().
Examples
getElections(chamber="all", update=FALSE)
Data on electorates since 1901
Description
Data on electorates since 1901
Usage
getElectorates()
Value
a tibble
Examples
getElectorates()
Known errors in the Parliamentary Handbook
Description
A table of values the package has found to be wrong in the Parliamentary
Handbook, with the corrected value and the evidence for it. By default the
get* functions return the Handbook's values and only mark these rows in
their handbook_flag column; with apply_errata = TRUE they replace the
value with corrected_value.
Usage
getErrata()
Details
An erratum applies only while the Handbook still has handbook_value, so
once the Handbook is fixed the erratum stops having any effect.
Value
a tibble with one row per correction: the table and row it applies
to (table, key), the field, the handbook_value, the
corrected_value, a short issue code, the evidence and its source.
Examples
getErrata()
Data on individuals and biographical information since 1901
Description
Data on individuals and biographical information since 1901
Usage
getIndividuals()
Value
a tibble
Examples
getIndividuals()
Data on Ministers since 1901
Description
Data on Ministers since 1901
Usage
getMinisters()
Value
a tibble with one row per ministerial role. RDateStart and
RDateEnd are the dates of the role; MDateStart and MDateEnd are the
dates of the ministry.
Examples
getMinisters()
Data on Ministries and Governing Parties since 1901
Description
Data on Ministries and Governing Parties since 1901
Usage
getMinistries()
Value
a tibble with one row per ministry and governing party. Ministries
for which the Handbook lists no party (e.g. the first Barton Ministry) are
kept, with Party and pID set to NA.
Examples
getMinistries()
Data on all listed prior occupations held (both primary and secondary)
Description
Data on all listed prior occupations held (both primary and secondary)
Usage
getOccupations()
Value
a tibble with one row per person and occupation
Examples
getOccupations()
Data on parliamentary tenures of MPs and senators since 1901
Description
By default the whole table is retrieved from the Handbook (one request).
If the Handbook cannot be reached, or update = FALSE, the copy stored in
the package is returned instead. The date the data was retrieved is in the
scraped attribute of the result.
Usage
getParlService(
chamber = c("all", "house", "senate"),
apply_errata = FALSE,
update = TRUE
)
Arguments
chamber |
choose to include MPs ("house"), senators ("senate") or both ("all"). |
apply_errata |
if TRUE, replace values listed in |
update |
if TRUE (the default), retrieve the current data from the Handbook; if FALSE, use the stored copy. |
Value
a tibble. DateEnd is NA for terms that have not ended.
handbook_flag marks rows with a known problem in the Handbook:
overlapping_term (the term starts before the member's previous term
ends), placeholder_end_date (a term that is not the member's latest has
no end date in the Handbook) and any issue listed in getErrata().
Examples
getParlService(chamber="house")
# the copy stored in the package, without querying the Handbook
getParlService(chamber="house", update=FALSE)
Data on Parliamentary terms since 1901
Description
Data on Parliamentary terms since 1901
Usage
getParliaments()
Value
a tibble
Examples
getParliaments()
Data on parties since 1901
Description
Data on parties since 1901
Usage
getParties()
Value
a tibble. Note that the Handbook gives a party a new pID when it
changes its name, and that abbreviations are not unique (three parties
use "LIB"), so Abbrev should not be used as a key.
Examples
getParties()
Data on party service of MPs and senators since 1901
Description
Returns the copy of the Handbook's party service records stored in the
package. The Handbook has no single source for these records (each
person's must be retrieved separately), so updating takes a few minutes and
is optional: with update = TRUE, the records of everyone who has joined
or served in parliament since the stored copy was taken are retrieved again.
The date of the stored copy is in the scraped attribute of the result,
and the date of any update in the updated attribute.
Usage
getPartyService(apply_errata = FALSE, update = FALSE)
Arguments
apply_errata |
if TRUE, replace values listed in |
update |
if TRUE, update the stored copy from the Handbook (about 250 requests, two to three minutes). Defaults to FALSE. |
Value
a tibble. handbook_flag marks rows with a known problem in the
Handbook: same_day_party_record (a one-day record that starts on the
same day as another party record for the same person),
placeholder_end_date (the Handbook has 1900-01-01, returned as NA) and
any issue listed in getErrata().
Examples
getPartyService()
Data on all listed Qualifications
Description
Data on all listed Qualifications
Usage
getQualifications()
Value
a tibble with one row per person and qualification
Examples
getQualifications()
Data on all listed Secondary Schools
Description
Data on all listed Secondary Schools
Usage
getSchools()
Value
a tibble with one row per person and school, as listed in the Handbook (some entries name more than one school)
Examples
getSchools()
Data on Shadow Ministers since 1901
Description
Data on Shadow Ministers since 1901
Usage
getShadowMinisters()
Value
a tibble with one row per shadow ministerial role. RDateStart
and RDateEnd are the dates of the role; MDateStart and MDateEnd are
the dates of the shadow ministry.
Examples
getShadowMinisters()
Data on sitting dates in the federal parliament
Description
Dates up to the end of the stored copy come from the package; by default,
later years are retrieved from the Handbook (one request per year). The
date of the stored copy is in the scraped attribute of the result, and
the date of any update in the updated attribute.
Usage
getSittingDates(apply_errata = FALSE, update = TRUE)
Arguments
apply_errata |
if TRUE, replace values listed in |
update |
if TRUE (the default), add sitting dates after the stored copy from the Handbook; if FALSE, use the stored copy only. |
Value
a tibble with one row per sitting date and whether each chamber
sat. handbook_flag marks dates listed in getErrata(), e.g.
chamber_did_not_sit.
Examples
getSittingDates()