Skip to content

Commit b564afe

Browse files
authored
Merge branch 'main' into issue_225
2 parents d8d75d1 + 380fc0f commit b564afe

17 files changed

+246
-214
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
R_KEEP_PKG_SOURCE: yes
3030

3131
steps:
32-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v4
3333

3434
- uses: r-lib/actions/setup-pandoc@v2
3535

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
env:
88
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111

1212
- uses: r-lib/actions/setup-r@v2
1313
with:

.github/workflows/pkgdown.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
permissions:
2121
contents: write
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424

2525
- uses: r-lib/actions/setup-pandoc@v2
2626

@@ -39,8 +39,8 @@ jobs:
3939

4040
- name: Deploy to GitHub pages 🚀
4141
if: github.event_name != 'pull_request'
42-
uses: JamesIves/github-pages-deploy-action@v4.4.1
42+
uses: JamesIves/github-pages-deploy-action@v4
4343
with:
4444
clean: false
4545
branch: gh-pages
46-
folder: docs
46+
folder: docs

.github/workflows/render-rmarkdown.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
4+
workflow_dispatch:
45
push:
5-
paths: ['**.Rmd']
6-
7-
name: render-rmarkdown.yaml
6+
paths: ['README.Rmd']
87

8+
name: render-rmarkdown.yml
99
permissions: read-all
1010

1111
jobs:
@@ -22,12 +22,15 @@ jobs:
2222
fetch-depth: 0
2323
- uses: r-lib/actions/setup-pandoc@v2
2424
- uses: r-lib/actions/setup-r@v2
25+
- uses: r-lib/actions/setup-r-dependencies@v2
26+
with:
27+
extra-packages: any::rmarkdown
2528

26-
- name: Render Rmarkdown files and Commit Results
29+
- name: Render README.Rmd and commit results
2730
run: |
28-
RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$'))
29-
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]}
31+
Rscript -e 'if (file.exists("README.Rmd")) rmarkdown::render("README.Rmd", output_format = "md_document")'
3032
git config --local user.name "$GITHUB_ACTOR"
3133
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
32-
git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit"
34+
git add man/figures/README*.png
35+
git commit README.Rmd README.md man/figures/README*.png -m 'Re-build Rmarkdown files' || echo "No changes to commit"
3336
git push origin || echo "No changes to commit"

.github/workflows/run-pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
env:
88
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111

1212
- name: "Run Pre Commit Hooks"
1313
run: ./pre-commit.sh

.github/workflows/test-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919

2020
- uses: r-lib/actions/setup-r@v2
2121
with:

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ S3method(print,ptd_spc_options)
66
S3method(ptd_spc,SharedData)
77
S3method(ptd_spc,data.frame)
88
S3method(summary,ptd_spc_df)
9+
S3method(to_datetime,Date)
10+
S3method(to_datetime,POSIXt)
11+
S3method(to_datetime,character)
912
export(GeomPTDIcon)
1013
export(geom_ptd_icon)
1114
export(ptd_create_ggplot)

R/to_datetime.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ to_datetime <- function(x) {
77
UseMethod("to_datetime")
88
}
99

10+
#' @export
1011
to_datetime.Date <- function(x) {
1112
as.POSIXct(x)
1213
}
1314

15+
#' @export
1416
to_datetime.POSIXt <- identity
1517

16-
18+
#' @export
1719
to_datetime.character <- function(x) {
1820
as.POSIXct(x)
1921
}

README.Rmd

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ Welcome to the NHS-R community's package for building a specific type of statist
5151
The help files and vignettes within this package tell you more about the possible options for controlling the charts, but below are some simple examples of the type of chart the package produces.
5252
We will use the `ae_attendances` dataset from the `{NHSRdatasets}` package and a bit of `{dplyr}` code to select some organisations.
5353

54-
```{r example, message=FALSE, warning=FALSE}
54+
```{r example1, message=FALSE, warning=FALSE}
5555
library(NHSRplotthedots)
5656
library(NHSRdatasets)
5757
library(dplyr)
5858
59-
sub_set <- ae_attendances %>%
59+
sub_set <- ae_attendances |>
6060
filter(org_code == "RQM", type == 1, period < as.Date("2018-04-01"))
6161
62-
sub_set %>%
62+
sub_set |>
6363
ptd_spc(
6464
value_field = breaches,
6565
date_field = period,
@@ -69,13 +69,13 @@ sub_set %>%
6969

7070
This plot is ok on its own, but we can specify more control options if we explicitly pass it on to the `plot()` function.
7171

72-
```{r}
73-
sub_set %>%
72+
```{r example2}
73+
sub_set |>
7474
ptd_spc(
7575
value_field = breaches,
7676
date_field = period,
7777
improvement_direction = "decrease"
78-
) %>%
78+
) |>
7979
plot(
8080
y_axis_label = "4-hour wait breaches",
8181
main_title = "SPC of A&E waiting time breaches for RQM"
@@ -85,28 +85,29 @@ sub_set %>%
8585
or, equivalently:
8686

8787
```r
88-
sub_set %>%
88+
sub_set |>
8989
ptd_spc(
9090
value_field = breaches,
9191
date_field = period,
9292
improvement_direction = "decrease"
93-
) %>%
93+
) |>
9494
ptd_create_ggplot(
9595
y_axis_label = "4-hour wait breaches",
9696
main_title = "SPC of A&E waiting time breaches for RQM"
9797
)
9898
```
99+
99100
You can also use the `summary()` function to get some basic statistics about your SPC data frame.
100101
The function prints the SPC options, and then returns the summarised results as a table:
101102

102-
```{r}
103-
summary <- sub_set %>%
103+
```{r summary-example}
104+
summary <- sub_set |>
104105
ptd_spc(
105106
value_field = breaches,
106107
date_field = period,
107108
improvement_direction = "decrease",
108109
target = 1200
109-
) %>%
110+
) |>
110111
summary()
111112
```
112113

@@ -124,12 +125,12 @@ It's also possible to generate interactive plots using the `{plotly}` package by
124125
This function takes the same arguments as `plot`/`ptd_create_ggplot`.
125126

126127
```r
127-
sub_set %>%
128+
sub_set |>
128129
ptd_spc(
129130
value_field = breaches,
130131
date_field = period,
131132
improvement_direction = "decrease"
132-
) %>%
133+
) |>
133134
ptd_create_plotly(
134135
y_axis_label = "4-hour wait breaches",
135136
main_title = "SPC of A&E waiting time breaches for RQM"
@@ -145,7 +146,7 @@ The package (from v0.2.0) supports annotating the values of the mean and the
145146

146147
The way to achieve this is to turn on the `label_limits` option:
147148

148-
```{r}
149+
```{r limits-example}
149150
sub_set |>
150151
ptd_spc(
151152
value_field = breaches,
@@ -184,7 +185,7 @@ vignette("intro", package = "NHSRplotthedots")
184185
vignette(package = "NHSRplotthedots")
185186
```
186187

187-
# Contribution
188+
# Contributing
188189

189190
This is an NHS-R Community project that is open for anyone to contribute to in any way that they are able.
190191
The project is released with a [Contributor Code of Conduct][coc].

0 commit comments

Comments
 (0)