Skip to content

Commit

Permalink
Merge pull request #8 from ThomUK/v0.1.1
Browse files Browse the repository at this point in the history
V0.1.1
  • Loading branch information
ThomUK authored Nov 17, 2022
2 parents e5b170f + ef8a1b1 commit 25466c7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SPCreporter
Title: Creates Metric Reports using Statistical Process Control in the NHS style
Version: 0.1.0
Version: 0.1.1
Authors@R:
person("Tom", "Smith", , "[email protected]", role = c("aut", "cre"))
Description: Takes a dataset file and a configuration file to produce an html
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# SPCreporter 0.1.0
# SPCreporter 0.1.1

## Bugfix

* Fixes an error occurring when targets are not set for any of the reported measures


# SPCreporter 0.1.0
## Initial Release

* spcr_make_data_bundle()
Expand Down
9 changes: 8 additions & 1 deletion R/spcr_calculate_row.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,19 @@ spcr_calculate_row <- function(ref, aggregation, measure_data, measure_config, r

x_date_format <- dplyr::if_else(aggregation == "week", "%d-%b-%Y", "%b '%y")

# ptd_spc function needs NULL for target when no target is set
if(is.na(target)){
spc_target <- NULL
} else {
spc_target <- target
}

# do the SPC calcs and store the results
spc <- NHSRplotthedots::ptd_spc(
subset_measure_data,
value_field = "value",
date_field = "date",
target = target,
target = spc_target, # set to NULL in code if NA in source data
# fix_after_n_points = #TODO
improvement_direction = tolower(improvement_direction)
)
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-spcr_make_data_bundle.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,21 @@ test_that("it returns a dataframe of the expected size", {
25
)
})

test_that("it works when no targets are set", {

# replace all targets with NA, as if not set
measure_config$target <- NA

r <- spcr_make_data_bundle(measure_data, report_config, measure_config)

expect_equal(
nrow(r),
6
)

expect_equal(
ncol(r),
25
)
})

0 comments on commit 25466c7

Please sign in to comment.