Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add render-rmarkdown.yml GH workflow #221

Merged
merged 38 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
049f479
Export S3 methods in to_datetime.R
francisbarton Aug 6, 2024
a99cd11
Edit test file to avoid lintr error
francisbarton Aug 6, 2024
fc7f895
Add render-rmarkdown.yml GH Action
francisbarton Aug 6, 2024
aea3685
Merge branch 'main' into render_rmd2
francisbarton Aug 6, 2024
7f76d41
Merge pull request #8 from francisbarton/render_rmd2
francisbarton Aug 6, 2024
b3f72ee
Update README.Rmd
francisbarton Aug 6, 2024
7477c50
Merge branch 'main' into issue_213_v2
francisbarton Aug 6, 2024
bb8c779
Merge pull request #9 from francisbarton/issue_213_v2
francisbarton Aug 6, 2024
9d6b0da
Update render-rmarkdown.yml
francisbarton Aug 6, 2024
ec48c7f
Merge branch 'render_rmd2'
francisbarton Aug 6, 2024
d5a4ad6
Try to avoid lintr error
francisbarton Aug 6, 2024
b5505d6
Merge pull request #10 from francisbarton/render_readme
francisbarton Aug 6, 2024
5c37e5d
Merge pull request #6 from francisbarton/issue_208_v2
francisbarton Aug 6, 2024
0e88fe0
Merge branch 'main' into render_rmd_v3
francisbarton Aug 6, 2024
853eb6d
Merge pull request #11 from francisbarton/render_rmd_v3
francisbarton Aug 6, 2024
9185336
remove the renv step from render-rmarkdown.yml
francisbarton Aug 6, 2024
8c95c2f
Merge pull request #12 from francisbarton/render_rmd_v3
francisbarton Aug 6, 2024
67a8539
Update render-rmarkdown.yml
francisbarton Aug 6, 2024
8197f1a
Replace magrittr pipe with base pipe in README
francisbarton Aug 6, 2024
c010b78
Merge pull request #13 from francisbarton/render_rmd_v3
francisbarton Aug 6, 2024
307d837
Add manual workflow dispatch to render-rmarkdown
francisbarton Aug 8, 2024
4c11835
Update render-rmarkdown.yml
francisbarton Aug 8, 2024
f33a746
Try to fix README render workflow code
francisbarton Aug 8, 2024
564d792
quote filename!
francisbarton Aug 8, 2024
9d1139f
Add git add line to Rmd render workflow script
francisbarton Aug 8, 2024
695c16e
Re-build Rmarkdown files
francisbarton Aug 8, 2024
c292cb3
Update README.Rmd
francisbarton Aug 8, 2024
8672087
Re-build Rmarkdown files
francisbarton Aug 8, 2024
c989b93
Use dev version of PTD to generate charts in README
francisbarton Aug 8, 2024
e1a8335
Add chunk labels to README where missing
francisbarton Aug 8, 2024
31fe0d6
Regenerate README charts
francisbarton Aug 8, 2024
b233ba5
Update R-CMD-check.yaml to use checkout@v4
francisbarton Aug 8, 2024
84bf449
Update pkgdown.yaml to use checkout@v4 and latest deploy @v4
francisbarton Aug 8, 2024
121fea1
Update lint.yaml to use checkout@v4
francisbarton Aug 8, 2024
827fed7
Update run-pre-commit-hooks.yaml to use checkout@v4
francisbarton Aug 8, 2024
f36d082
Update test-coverage.yaml to use checkout@v4
francisbarton Aug 8, 2024
86d1c70
Re-export work on README in main out to PR branch
francisbarton Aug 8, 2024
41ca9f9
Re-build Rmarkdown files
francisbarton Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 10 additions & 10 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,16 +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

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

- 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 "[email protected]"
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
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