Skip to content

Commit

Permalink
Revert "Merge branch 'main' into render_rmd2"
Browse files Browse the repository at this point in the history
This reverts commit aea3685, reversing
changes made to fc7f895.
  • Loading branch information
francisbarton committed Aug 6, 2024
1 parent aea3685 commit 6efff45
Show file tree
Hide file tree
Showing 11 changed files with 706 additions and 706 deletions.
1 change: 1 addition & 0 deletions .github/workflows/render-rmarkdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths: ['README.Rmd']

name: render-rmarkdown.yml

permissions: read-all

jobs:
Expand Down
9 changes: 3 additions & 6 deletions .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ linters: linters_with_defaults(
line_length_linter(120),
cyclocomp_linter(23),
indentation_linter(hanging_indent_style = "tidy"),
object_name_linter("snake_case"),
trailing_blank_lines_linter = NULL
)
object_name_linter("snake_case"))
exclusions: list(
"R/ptd_spc_colours.R" = 5
)
"R/ptd_spc_colours.R" = 5)
exclude: "# Exclude Linting|#\\s?nolint"
exclude_start: "# Begin Exclude Linting|#\\s?nolint-start"
exclude_end: "# End Exclude Linting|#\\s?nolint-end"

encoding: "ISO-8859-1"
34 changes: 14 additions & 20 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@ Type: Package
Title: Draw XmR Charts for NHSE/I 'Making Data Count' Programme
Version: 0.1.0.9000
Authors@R: c(
person("Christopher", "Reading", ,"christopher.reading1@nhs.net", c("cre", "aut")),
person("Simon", "Wellesley-Miller", ,"simon.wellesley-miller@nhs.net", "aut"),
person("Zoë", "Turner", , "Zoe.Turner2@nottshc.nhs.uk", "aut", comment = c(ORCID = "0000-0003-1033-9158")),
person("Tom", "Jemmett", ,"thomas.jemmett@nhs.net", "aut", comment = c(ORCID="0000-0002-6943-2990")),
person("Tom", "Smith", ,"thomas.smith5@nuh.nhs.uk", "aut"),
person("Chris", "Mainey", ,"c.mainey@nhs.net", "aut", comment = c(ORCID ="0000-0002-3018-6171")),
person("John", "MacKintosh", ,"john.mackintosh3@nhs.scot", "aut"),
person("Marcos", "Fabietti", ,"marcos.fabietti@nuh.nhs.uk", "aut"),
person("Fran", "Barton",
email = "francis.barton@nhs.net",
role = "aut",
comment = c(ORCID = "0000-0002-5650-1176")
),
person("NHS-R community",
email = "nhs.rcommunity@nhs.net",
role = "cph"
person("Christopher", "Reading", ,"christopher.reading1@nhs.net", c("cre", "aut")),
person("Simon", "Wellesley-Miller", ,"simon.wellesley-miller@nhs.net", "aut"),
person("Zoë", "Turner", , "Zoe.Turner2@nottshc.nhs.uk", "aut", comment = c(ORCID = "0000-0003-1033-9158")),
person("Tom", "Jemmett", ,"thomas.jemmett@nhs.net", "aut", comment = c(ORCID="0000-0002-6943-2990")),
person("Tom", "Smith", ,"thomas.smith5@nuh.nhs.uk", "aut"),
person("Chris", "Mainey", ,"c.mainey@nhs.net", "aut", comment = c(ORCID ="0000-0002-3018-6171")),
person("John", "MacKintosh", ,"john.mackintosh3@nhs.scot", "aut"),
person("Marcos", "Fabietti", ,"marcos.fabietti@nuh.nhs.uk", "aut"),
person("NHS-R community", email = "nhs.rcommunity@nhs.net", role = "cph")
)
)
Maintainer: Christopher Reading <christopher.reading1@nhs.net>
Description: Provides tools for drawing Statistical Process Control (SPC) charts. This package supports the NHSE/I programme 'Making Data Count', and allows users to draw XmR charts, use change points and apply rules with summary indicators for when rules are breached.
Description: Provides tools for drawing Statistical Process Control (SPC) charts. This package supports the NHSE/I
programme 'Making Data Count', and allows users to draw XmR charts, use change points and apply rules with summary
indicators for when rules are breached.
URL: https://nhs-r-community.github.io/NHSRplotthedots,
https://github.com/nhs-r-community/NHSRplotthedots
BugReports: https://nhs-r-community.github.io/NHSRplotthedots/issues
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Imports:
assertthat,
Expand Down Expand Up @@ -61,4 +55,4 @@ Suggests:
Depends: R (>= 4.1.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
Language: en-GB
Language: en-US
100 changes: 70 additions & 30 deletions R/ptd_create_ggplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ ptd_create_ggplot <- function(
sec_breaks <- .data |>
# should already be sorted in date order but just in case
dplyr::arrange(x) |>
dplyr::select(c("lpl", "mean_col", "upl")) |>
dplyr::select(all_of(c("lpl", "mean_col", "upl"))) |>
dplyr::slice_tail(n = 1) |>
unlist() |>
unname()
Expand All @@ -248,53 +248,93 @@ ptd_create_ggplot <- function(
start <- floor(min(yaxis, na.rm = TRUE) / y_axis_breaks) * y_axis_breaks
end <- max(yaxis, na.rm = TRUE)
y_axis_labels <- seq(from = start, to = end, by = y_axis_breaks)
} else {
# if no y-axis breaks supplied by user, we just use the built-in heuristic
y_axis_labels <- ggplot2::waiver()
}

# Nested combinations of 3 binary options = 2^3 (8) possible plot designs
if (percentage_y_axis) {
if (!is.null(y_axis_breaks)) {
if (label_limits) {
# %age axes + specified breaks + sec labelling axis
plot <- plot +
ggplot2::scale_y_continuous(
breaks = y_axis_labels,
labels = scales::label_percent(accuracy = y_axis_breaks),
sec.axis = ggplot2::sec_axis(
trans = identity,
name = NULL,
breaks = sec_breaks,
labels = scales::label_percent(accuracy = y_axis_breaks)
)
)
} else {
# %age axes + specified breaks - no sec labelling axis
plot <- plot +
ggplot2::scale_y_continuous(
breaks = y_axis_labels,
labels = scales::label_percent(accuracy = y_axis_breaks)
)
}
} else if (label_limits) {
# %age axes + sec labelling axis - no specified breaks
plot <- plot +
ggplot2::scale_y_continuous(
labels = scales::label_percent(accuracy = y_axis_breaks),
sec.axis = ggplot2::sec_axis(
trans = identity,
name = NULL,
breaks = sec_breaks,
labels = scales::label_percent(accuracy = y_axis_breaks)
)
)
} else {
# %age axes - no specified breaks - no sec labelling axis
plot <- plot +
ggplot2::scale_y_continuous(
labels = scales::label_percent(accuracy = y_axis_breaks)
)
}
} else if (!is.null(y_axis_breaks)) {
if (label_limits) {
# percentage y-axis, secondary labelling axis
# integer axes + specified breaks + sec labelling axis
plot <- plot +
ggplot2::scale_y_continuous(
breaks = y_axis_labels, # see above - can mean "just use waiver()"
labels = scales::label_percent(),
breaks = y_axis_labels,
labels = scales::label_number(accuracy = y_axis_breaks),
sec.axis = ggplot2::sec_axis(
transform = identity,
trans = identity,
name = NULL,
breaks = sec_breaks,
labels = scales::label_percent(accuracy = 0.1)
labels = scales::label_number(accuracy = 0.01)
)
)
} else {
# percentage y-axis, no secondary labelling axis
# integer axes + specified breaks - no sec labelling axis
plot <- plot +
ggplot2::scale_y_continuous(
breaks = y_axis_labels,
labels = scales::label_percent()
labels = scales::label_number(accuracy = y_axis_breaks)
)
}
} else if (label_limits) {
# integer y-axis, secondary labelling axis
plot <- plot +
ggplot2::scale_y_continuous(
breaks = y_axis_labels,
labels = scales::label_number(),
sec.axis = ggplot2::sec_axis(
transform = identity,
name = NULL,
breaks = sec_breaks,
labels = scales::label_number()
)
)
} else {
# integer y-axis, no secondary axis
plot <- plot +
ggplot2::scale_y_continuous(
breaks = y_axis_labels,
labels = scales::label_number()
)
if (label_limits) {
# integer axes + sec labelling axis - no specified breaks
plot <- plot +
ggplot2::scale_y_continuous(
labels = scales::label_number(accuracy = y_axis_breaks),
sec.axis = ggplot2::sec_axis(
trans = identity,
name = NULL,
breaks = sec_breaks,
labels = scales::label_number(accuracy = 0.01)
)
)
} else {
# integer axes - no specified breaks - no sec labelling axis
plot <- plot +
ggplot2::scale_y_continuous(
labels = scales::label_number(accuracy = y_axis_breaks)
)
}
}


Expand Down
Loading

0 comments on commit 6efff45

Please sign in to comment.