NHSRplotthedots
NHSRplotthedots copied to clipboard
Add helper functions for variation and assurance types
proposed functions will simplify reporting from underlying spc data. They may already be partially implemented as internal functions to support calculation of the variation and assurance logos.
ptd_get_variation_type()
ptd_get_assurance_type()
Here are the functions implemented in the {SPCreporter} package:
https://github.com/ThomUK/SPCreporter/blob/5ab1d01129f049f85b0ce01f92255a6c28f11c39/R/spcr_get_variation_type.R https://github.com/ThomUK/SPCreporter/blob/5ab1d01129f049f85b0ce01f92255a6c28f11c39/R/spcr_get_assurance_type.R
Add to summary()
I think a lot of this already exists:
-
ptd_calculate_point_type()
is used in the spc calculations and gives for each point a string like "common_cause", "speial_cause_concern" -
ptd_calculate_assurance_type()
summarises the data (to give one row per facet group) and gives a string like "consistent_pass", "consistent_fail" -
summary()
uses these functions and returns a table like the below:
# A tibble: 6 x 10
f mean lpl upl n common_cause special_cause_improvement special_cause_concern point_type assurance_type
<fct> <dbl> <dbl> <dbl> <int> <dbl> <int> <int> <chr> <chr>
1 R1H 5410. 3946. 6874. 24 12 10 2 common_cause consistent_fail
2 R1K 3922. 2119. 5725. 24 10 7 7 common_cause consistent_fail
3 RJ7 1487. 727. 2247. 24 12 8 4 special_cause_concern consistent_fail
4 RJC 398. 166. 630. 24 0 17 7 special_cause_concern consistent_fail
5 RQM 1545. 740. 2350. 24 20 2 2 common_cause consistent_fail
6 RRK 1712. 850. 2574. 24 15 8 1 common_cause consistent_fail
one thing to note, I don't think that this is documented in any of the vignettes or readme so could do with being added to those
You're right, it is implemented but I think was broken until this commit yesterday (in the plotly branch): cffe05747153c9446358f7d925cf626a4e8c14b6 In the main branch, variation_type appears in the summary, but point_type is missing.
I think we should change "point_type" to "variation_type" for consistency with the training and icon names... Agree too on the readme update.
renamed column in #176 - the function it utilises calls the column point type when it's normally used as it is generating for each point. but this is summarised to a single point, so variation_type makes sense.
I think let's merge #176 then update the docs to describe the summary function (rather than bloating that PR too much more than it already is)
closing in favour of #184 which describes the new ask