-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
67 lines (52 loc) · 2.47 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# readaihw
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/readaihw)](https://CRAN.R-project.org/package=readaihw)
[![R-CMD-check](https://github.com/RWParsons/readaihw/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/RWParsons/readaihw/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/RWParsons/readaihw/graph/badge.svg)](https://app.codecov.io/gh/RWParsons/readaihw)
<!-- badges: end -->
The purpose of `readaihw` is to provide access to the MyHospitals API so that hospital data from the AIHW can be accessed directly from R. For details about what data are provided by the AIHW see [here](https://www.aihw.gov.au/about-our-data/our-data-collections). See [here](https://www.aihw.gov.au/reports-data/myhospitals/content/api) for details about the [MyHospital API](https://myhospitalsapi.aihw.gov.au/index.html).
## Installation
You can install the development version of readaihw like so:
``` r
# install.packages("pak")
pak::pkg_install("RWParsons/readaihw")
```
## Example - ED presentations
This example gets data on hospital presentations and presents these counts as a graph for hospitals in the ACT local hospital network over time.
```{r example, message=FALSE, warning=FALSE}
library(readaihw)
library(dplyr)
library(ggplot2)
ed_presentations <- read_flat_data_extract("MYH-ED")
act_hospital_codes <- get_hospital_mappings() |>
filter(
local_hospital_network_lhn == "Australian Capital Territory",
type == "Hospital"
) |>
pull(code)
ed_presentations |>
filter(reporting_unit_code %in% act_hospital_codes) |>
select(date = reporting_end_date, hospital = reporting_unit_name, value) |>
mutate(value = as.numeric(value), date = lubridate::ymd(date)) |>
summarize(count = sum(value, na.rm = TRUE), .by = c(hospital, date)) |>
ggplot(aes(date, count)) +
geom_line() +
geom_point() +
facet_wrap(~ stringr::str_wrap(hospital, 40)) +
theme_bw() +
scale_y_continuous(labels = scales::label_comma()) +
labs(x = "", y = "ED Presentations (n)", title = "ED presentations in the ACT LHN")
```