An open API service indexing awesome lists of open source software.

https://github.com/jonocarroll/sahansard

Wraps the SA Parliament Hansard API
https://github.com/jonocarroll/sahansard

api-wrapper australia hansard parliament politics r

Last synced: about 1 year ago
JSON representation

Wraps the SA Parliament Hansard API

Awesome Lists containing this project

README

          

---
output: github_document
---

# SA Hansard

![](http://www.parliament.sa.gov.au/_layouts/PII3.InternetStyles/LACQUER/hdrCrest.jpg)

[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/SAHansard)](https://cran.r-project.org/package=SAHansard)

Wraps the SA Hansard API (http://parliament-api-docs.readthedocs.io/en/latest/south-australia/), producing "tidy" `data.frame` objects or rendering the resulting HTML.

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
suppressPackageStartupMessages(source("R/scrape.R"))
```

## Installation

This package can be installed from GitHub using the `devtools::install_github` method:

```{r, eval=FALSE}
devtools::install_github("jonocarroll/SAHansard")
```

## Examples

Obtain all SA Hansard records for a given year

```{r, cache=TRUE}
hansard_year(year = "2017")
```

From these, a given Table of Contents can be obtained (for a given `docid` from `hansard_year`)

```{r, cache=TRUE}
# normally just evaluating hansard_toc is what you want,
# here I only want to show limited results
glimpse(hansard_toc(docid = 'HANSARD-10-19980'))
```

From these, a HTML fragment can be obtained (use the `pdfid` from `hansard_toc`)

***
```{r, cache=TRUE, results='asis'}
# the print method for this result opens the
# rendered HTML fragment in the RStudio Viewer with
# CSS obtained from the Hansard site.
# Here I am just printing the content
hansard_fragment(pdfid = 'HANSARD-10-19961')$content
```

***