Skip to content

Commit

Permalink
Merge branch 'main' into issue_192
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjemmett authored Aug 21, 2024
2 parents a73f191 + efba187 commit 938abcd
Show file tree
Hide file tree
Showing 19 changed files with 678 additions and 645 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

Expand All @@ -39,8 +39,8 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4
with:
clean: false
branch: gh-pages
folder: docs
folder: docs
18 changes: 10 additions & 8 deletions .github/workflows/render-rmarkdown.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_dispatch:
push:
paths: ['**.Rmd']

name: render-rmarkdown.yaml
paths: ['README.Rmd']

name: render-rmarkdown.yml
permissions: read-all

jobs:
Expand All @@ -22,14 +22,16 @@ jobs:
fetch-depth: 0

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

- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rmarkdown

- name: Render Rmarkdown files and Commit Results
- name: Render README.Rmd and commit results
run: |
RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$'))
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]}
Rscript -e 'if (file.exists("README.Rmd")) rmarkdown::render("README.Rmd", output_format = "md_document")'
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit"
git add man/figures/README*.png
git commit README.Rmd README.md man/figures/README*.png -m 'Re-build Rmarkdown files' || echo "No changes to commit"
git push origin || echo "No changes to commit"
2 changes: 1 addition & 1 deletion .github/workflows/run-pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: "Run Pre Commit Hooks"
run: ./pre-commit.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
1 change: 0 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ exclusions: list(
exclude: "# Exclude Linting|#\\s?nolint"
exclude_start: "# Begin Exclude Linting|#\\s?nolint-start"
exclude_end: "# End Exclude Linting|#\\s?nolint-end"

3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ S3method(print,ptd_spc_options)
S3method(ptd_spc,SharedData)
S3method(ptd_spc,data.frame)
S3method(summary,ptd_spc_df)
S3method(to_datetime,Date)
S3method(to_datetime,POSIXt)
S3method(to_datetime,character)
export(GeomPTDIcon)
export(geom_ptd_icon)
export(ptd_create_ggplot)
Expand Down
4 changes: 3 additions & 1 deletion R/to_datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ to_datetime <- function(x) {
UseMethod("to_datetime")
}

#' @export
to_datetime.Date <- function(x) {
as.POSIXct(x)
}

#' @export
to_datetime.POSIXt <- identity


#' @export
to_datetime.character <- function(x) {
as.POSIXct(x)
}
31 changes: 16 additions & 15 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ Welcome to the NHS-R community's package for building a specific type of statist
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.
We will use the `ae_attendances` dataset from the `{NHSRdatasets}` package and a bit of `{dplyr}` code to select some organisations.

```{r example, message=FALSE, warning=FALSE}
```{r example1, message=FALSE, warning=FALSE}
library(NHSRplotthedots)
library(NHSRdatasets)
library(dplyr)
sub_set <- ae_attendances %>%
sub_set <- ae_attendances |>
filter(org_code == "RQM", type == 1, period < as.Date("2018-04-01"))
sub_set %>%
sub_set |>
ptd_spc(
value_field = breaches,
date_field = period,
Expand All @@ -69,13 +69,13 @@ sub_set %>%

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

```{r}
sub_set %>%
```{r example2}
sub_set |>
ptd_spc(
value_field = breaches,
date_field = period,
improvement_direction = "decrease"
) %>%
) |>
plot(
y_axis_label = "4-hour wait breaches",
main_title = "SPC of A&E waiting time breaches for RQM"
Expand All @@ -85,28 +85,29 @@ sub_set %>%
or, equivalently:

```r
sub_set %>%
sub_set |>
ptd_spc(
value_field = breaches,
date_field = period,
improvement_direction = "decrease"
) %>%
) |>
ptd_create_ggplot(
y_axis_label = "4-hour wait breaches",
main_title = "SPC of A&E waiting time breaches for RQM"
)
```

You can also use the `summary()` function to get some basic statistics about your SPC data frame.
The function prints the SPC options, and then returns the summarised results as a table:

```{r}
summary <- sub_set %>%
```{r summary-example}
summary <- sub_set |>
ptd_spc(
value_field = breaches,
date_field = period,
improvement_direction = "decrease",
target = 1200
) %>%
) |>
summary()
```

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

```r
sub_set %>%
sub_set |>
ptd_spc(
value_field = breaches,
date_field = period,
improvement_direction = "decrease"
) %>%
) |>
ptd_create_plotly(
y_axis_label = "4-hour wait breaches",
main_title = "SPC of A&E waiting time breaches for RQM"
Expand All @@ -145,7 +146,7 @@ The package (from v0.2.0) supports annotating the values of the mean and the

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

```{r}
```{r limits-example}
sub_set |>
ptd_spc(
value_field = breaches,
Expand Down Expand Up @@ -184,7 +185,7 @@ vignette("intro", package = "NHSRplotthedots")
vignette(package = "NHSRplotthedots")
```

# Contribution
# Contributing

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

0 comments on commit 938abcd

Please sign in to comment.