
Changelog
autospc 0.3.0
This release adds U and U’ charts, restarts of the algorithm (forced, and after a long gap), ranges in which limits may not be re-established, and a choice of how the dispersion chart of a pair establishes its limits. It makes the changes announced in 0.2.0: the default of max_exclusions is now 0, show_mr, write_table and facet_stages(split_rows) are removed, and no_regrets = TRUE with overhanging_reversions = FALSE is an error. It brings together development versions 0.2.0.9001 to 0.2.0.9015.
Lifecycle changes
Breaking changes
Defaults that change results
The default of
max_exclusionsis now 0 (#282), so that points are excluded from a period’s limits only when you ask for it. Whenever points were excluded under the old default of 3, the limits will differ under the default, and where they are re-established can change. Setmax_exclusions = 3to keep the results of 0.2.0. The warning 0.2.0 gave whenmax_exclusionswas left unset is gone.The algorithm restarts after a long gap (#325). The new argument
restart_after_gapdefaults toperiod_min, so results change for a series with a run of at least that many consecutive points with no value: a calculation period before the gap no longer takes points from after it, and limits are no longer carried across the gap.restart_after_gap = Infkeeps the behaviour of 0.2.0.
Results that change
With
no_regrets = TRUE, the default, adding a point to the end of a series can no longer move a re-establishment of limits to an earlier point (#308). This happened when the final run of a candidate calculation period was on the opposite side of the candidate centre line and continued to the end of the data. The algorithm now stops at such a candidate, so some re-establishments are made only once a few more points have been added. Only the end of a series is affected.A calculation period whose standard deviation cannot be estimated (a C’ or P’ period with no variation, or an Xbar period made up only of subgroups of one) no longer takes limits or
sbarfrom the previous period (#310). Its display rows keep its centre line and have no limits, and the shift rule applies to them as usual, so limits can be re-established after it.Where the first value of the series, or of a segment after a restart, is missing, the MR chart’s calculation period now starts at the same point as the X chart’s, the first point with a value (#326). It started at the first row, so the MR chart had limits on rows where neither chart had a value.
Changes to the drawing
The floating median is drawn in
firebrick3with long dashes, in place of grey, which was often hard to see (#315). Its label sits just after the end of the line, atannotation_size, and the horizontal axis is extended to make room for it (#316). It is drawn only as far as the last point with a value in its segment.The line joining the points breaks at each row whose value is missing, rather than running straight across it (#321). Time points absent from the data are not treated as missing: to break the line there, add a row with the value
NA. The analysis is unchanged.The vertical axis. A series too short for limits is drawn on the same axis as a chart of its type with limits, so the axis of a count, rate or proportion chart starts at zero, and its labels follow the scale of the breaks rather than being rounded to whole numbers (#339). A chart whose values, centre line and limits are all equal, as where they are all zero, is drawn from that value to one more (#314).
The legends always appear in the same order: “Rule triggered”, then “Period Type”, then the legends for restarts and prevented ranges. Before, ggplot2 chose the order.
The table plot_chart = FALSE returns
- A new column,
restart, isTRUEat the first row of each segment after a restart, forced or after a gap.
Removed
autospc(show_mr),facet_stages(show_mr)andautospc(write_table), deprecated since 0.1.0, are removed (#240, #244). Supplyingshow_mrorwrite_tabletoautospc()is now R’s own “unused argument” error. Usechart_type = "X"(or"Xbar") for the location chart on its own, andplot_chart = FALSE, oras.data.frame()on the plot, for the results table.facet_stages(split_rows), deprecated in 0.2.0, is removed. Usesplit_at, which counts points in the analysed series rather than rows of the data; where the data already holds one row per subgroup, inxorder, the two are the same.no_regrets = TRUEwithoverhanging_reversions = FALSEis an error (#243), of class"autospc_inconsistent_ssa_parameters_error". It was deprecated in 0.2.0, and changedoverhanging_reversionsto TRUE with a warning. Setoverhanging_reversions = TRUE, or leave it at its default, or setno_regrets = FALSE.
New features
U and U’ charts (#227).
chart_type = "U"draws a U chart of rates: a count of eventsyover the area of opportunitynin which they could occur, such as infections per 1,000 central line days. Its control limits vary withn.chart_type = "U'"draws Laney’s U’ chart (Laney, 2002), whose limits are also widened where the rates vary from subgroup to subgroup by more than a Poisson count would.nneed not be a whole number, and rows that share anxare summed into one subgroup. Seevignette("data-requirements").Forced restarts (#119).
force_restart_atmakes the algorithm restart at one or more values on the horizontal axis. Each segment is analysed as if it were a series of its own: its first calculation period isbaseline_lengthpoints, a segment with fewer thanperiod_minpoints has no limits, and no run counts towards the shift rule across a restart. Each restart is drawn as a solid vertical line, with the legend entry “Forced restart”. A floating median can be drawn at the end of each segment long enough for one.Restarts after a long gap (#325).
restart_after_gap(see above) restarts the algorithm at the first point with a value after a run of at least that many points with no value. For a pair, gaps are counted on the location chart, so both charts restart at the same point. A restart after a gap is drawn as a dotted line, with the legend entry “Restart after gap”.Ranges in which limits may not be re-established (#119).
prevent_establishment_ingives one or more ranges of the horizontal axis in which the algorithm may not establish new limits; the first calculation period of the series, and the first after each restart, are not affected. Each range is shaded light grey, with the legend entry “Re-establishment prevented”.-
How the dispersion chart of a pair establishes its limits (#115). The new argument
dispersion_chart_establishmentapplies to the MR chart of"XMR"and the S chart of"XbarS":-
"independent", the default, runs the algorithm on the dispersion chart separately from the location chart, as before; -
"forced"uses the location chart’s calculation periods, so the dispersion chart’s limits change where the location chart’s do; -
"shared"extends each calculation period until both charts have at leastperiod_minpoints with a value in it, and both charts use these periods.
With
"forced"or"shared", an MR chart leaves the moving range at the start of each later calculation period out of that period’s limits, because it spans two periods; this does not count towardsmax_exclusions. Printing the chart adds the line “Calculation periods mirror the … chart”. Infacet_stages(), which draws a pair as its location chart,"shared"gives each facet’s location chart the shared periods. The argument is ignored, with a warning, for a chart type that is not a pair. -
display_window = c(start, end)shows part of the horizontal axis without changing the analysis (#317). Every calculation period that overlaps the range has its centre line labelled, andfacet_stages()applies the range to every facet.floating_median_style, a list ofcolour,linetypeandlinewidth, sets how the floating median is drawn (#315), andfloating_median_labelschooses which floating medians are labelled where a series restarts and so has more than one:"last"(the default),"all","gaps"or"none"(#330).The algorithm log records the new events with new codes:
0000(a forced restart),0010(a restart after a gap),0720(a candidate rejected because its final run is not complete),0730(a candidate in a prevented range, not considered), and0800and0810(limits established or re-established on a dispersion chart, forced by the location chart). The table of log codes invignette("stable-shift-algorithm")lists every code the log can record.Speed. The analysis runs about ten times faster, and a drawn chart about two and a half to three times faster. Results are unchanged.
Bug fixes
An X or Xbar chart whose upper limit is negative no longer fails with “invalid ‘nsmall’ argument”; the top of its vertical axis is above the data, and its centre line labels are drawn outside the limits rather than inside them (#314).
A C’ chart where every value is zero no longer warns “no non-missing arguments to max”, and is drawn with a vertical axis from 0 to 10 (#314).
A chart whose first value is missing labels its first centre line, as does a dispersion chart whose first calculation period starts later than the location chart’s (#326).
Where there is no further shift rule break, the log reads “Sufficient data to proceed.” rather than adding “Moving counter to the next shift rule break, commencing at point NA.” (#340).
The “Period Type” legend shows “Calculation” when the first rows of the chart have no limits, as for a series that begins with missing values. It showed only “Display”.
facet_stages()labels the floating median in every facet that has one, not only in the last, and draws a median’s label only in the facet that holds it.The floating median is no longer drawn behind the keys of the “Rule triggered” legend.
Documentation
-
mr_screen_max_loopsapplies to the screening of moving ranges in C’, P’ and U’ charts as well as X charts; its documentation now says so, and that 0 turns the screening off. Theautospc.rounded_constantsoption documentation names the C’ and P’ charts, which use d2, and D4 in their screening of moving ranges.
autospc 0.2.0
This release adds the XbarS chart, improves handling of missing values, and returns the same table columns for a given chart type whatever the (valid) data. It also announces that the default of max_exclusions changes to 0 in 0.3.0. It brings together development versions 0.1.0.9001 to 0.1.0.9028.
Lifecycle changes
Breaking changes
The table plot_chart = FALSE returns
The analysed values have a column of their own.
seriesholds the values the algorithm analyses and the chart plots: theyvalues as supplied on a C, C’ or X chart, the moving ranges on an MR chart, and percentages on a P or P’ chart.ynow holds what the caller supplied, aggregated where the chart type aggregates; on an MR chart it held the moving ranges, and on a P or P’ chart the percentages.y_numeratoris gone: on a P or P’ chart the count is nowy. Code using the analysed values ory_numeratorfrom an MR, P or P’ chart needsseriesin place ofy, andyin place ofy_numerator. The columns are orderedx,series,y, and then the denominatornwhere the chart type has one.-
autospc(plot_chart = FALSE)andas.data.frame()on a plot return the same table.-
cl_label,annotation_levelandannotation_curvatureare no longer included. They are properties of the drawing rather than of the analysis. -
highlightnow marks only the rules a point breaks. The rule highlight of an excluded point was overwritten by the exclusion mark, masking the rule it broke. The plot is unchanged. - The floating median and the rows
extend_limits_toadds are part of the analysis, soas.data.frame()on a plot carries them. -
show_limitsno longer changes the table. - A new column,
limit_extension, is TRUE on the rowsextend_limits_toadds beyond the end of the data and FALSE on every other row. Those rows no longer copy the last subgroup’s denominator and numerator; they hold the limits, the period they continue, and nothing else.
-
A given chart type returns the same columns, in the same order and of the same types, whatever the data and the other arguments. A series too short to establish limits used to be returned with only the columns the data preparation had added; it now has every column, with NA where the analysis would have recorded a result.
limit_extensionis FALSE there rather than NA. An XmR chart’s two halves are joined whether or not limits were established. Themediancolumn is always returned, holding no value where no floating median was drawn.Every chart type returns a new column,
sd_estimate, an estimate of the standard deviation of a single observation on the same scale as the centre line - for examplesqrt(cl)for a C chart, and the mean moving range over d2 for an X chart.P and P’ charts no longer return
constant,pbar,ucl_displayandlcl_display. They held working values from extending limits over a display period.pbariscl, and the limits at any denominatornsit3 * sd_estimate / sqrt(n)either side of the centre line.
Results that change
-
Missing values. The analysis now proceeds as though a point with no
ywere not there, rather than walking over it as a row. This changes results for any series that has one.- A calculation period now holds
period_minpoints, notperiod_minrows. Where a series had missing values inside the first period, limits were previously calculated from fewer points than asked for. - Control limits now carry across a gap, as the centre line already did.
- No limits are drawn before the first point or after the last.
- A missing point no longer silently splits a run, which had made a shift rule break disappear. The new argument
na_ends_runcontrols this, and defaults toTRUE, the previous behaviour. A missing point may have continued the run before it or been on the other side of the centre line, and the data cannot say which:TRUEminimises the risk of a false positive shift rule break arising from missing data,FALSEminimises the risk of a false negative. - An MR chart now shows its control limits at the first point as well as its centre line. The limits themselves are unchanged.
- On a P or P’ chart, the limits at a point with missing
yare calculated from that point’s own denominator where the data supplied one, and the denominator is reported in the table. Where the denominator is missing or zero the limits are drawn at the mean denominator of the point’s period, leaving out excluded points and subgroups with no observation. - The period columns are now filled in at a point with missing
y, and the centre line and limits at such a point inside a display period match the rest of that period.
- A calculation period now holds
A point on the centre line no longer ends the run it sits in. A point within
centre_line_toleranceof the centre line neither commences a run, ends one, nor counts towards the length of the one it sits in, which is the conventional treatment of a point that is neither above the line nor below it.The exact values of d2 and D4 are used. They were written into the code as the published values to three decimal places, 1.128 and 3.267. The limits of an X, C’ or P’ chart sit 0.034% closer to the centre line than before, and an MR chart’s upper limit is 0.014% lower. These are the ratios of the exact to the rounded constants. Where a moving range or a point lies within that margin of a limit, the screening of moving ranges or a rule 1 break can differ as well. Centre lines, and C and P charts, are unchanged.
options(autospc.rounded_constants = TRUE)restores the rounded values.Control limits are constrained to the range the statistic can take. A P or P’ chart’s upper limit is constrained to at most 100%, previously this applied only in display periods. A percentage chart’s vertical axis follows the limits and the points where they reach outside 0 to 100. This only affected uninformative limits, and data points outside the valid range.
options(autospc.constrain_limits = FALSE)draws unconstrained limits, where the calculation puts them.-
Limits extended beyond the data.
- The extension starts where the next subgroup would have been: one median gap between consecutive subgroups past the last, capped at half the extension, rather than one unit of
x. On a chart whosexis spaced about one unit apart nothing changes; on monthlyDatedata the first row of the extension moves from one day past the last subgroup to one month past it. - A P’ chart’s extended limits use the standard deviation estimate of the period they extend. Previously, they were recalculated for the extension from that period’s data, with the z score of each point in the period standardised at the period’s mean denominator rather than at the point’s own, and with the moving ranges formed differently around a subgroup with no observation. Where the period’s denominators vary, the extended limits were previously too wide, and are now narrower.
- On a P chart, the centre line of extension rows, and the limits around it, are those of the period being extended. Previously, Where a point had been excluded from that period, the extension recalculated the centre line from averaged denominators, which gave a different value.
- The extension of a P or P’ chart uses the final calculation period’s mean denominator, leaving out excluded points and subgroups with no observation.
Only rows added by
extend_limits_toare affected by these changes, so they do not affect centre lines, control limits or rule breaks within the data. - The extension starts where the next subgroup would have been: one median gap between consecutive subgroups past the last, capped at half the extension, rather than one unit of
Data that is refused
X, MR and XMR charts reject a repeated
x. Each point on these charts is one row, so a repeatedxhas no place to be plotted. It was previously accepted, and multiplied in the output table. The error names the values that are repeated. The other chart types combine the rows that share anxinto one subgroup, as before.A P or P’ chart refuses counts it cannot plot.
ymust be a count from 0 ton, andncannot be negative. The error names the rows at fault and their values, up to five of them. A subgroup withn = 0andy = 0is still drawn as a gap. A series whose counts are valid is unaffected.
Removed
-
autospc(override_annotation_dist)andautospc(override_annotation_dist_P), defunct since 0.1.0, are gone from the signature. Supplying one is now R’s own “unused argument” error. Useupper_annotation_sfandlower_annotation_sfinstead:override_annotation_dist = 10becomesupper_annotation_sf = 1.1.
Deprecations
The default of
max_exclusionswill change from 3 to 0 in 0.3.0, so that points are excluded from a period’s limits only where you ask for it. Wherever points are excluded the change moves the limits, and can change where they are re-established. Until then,autospc()andfacet_stages()warn whenmax_exclusionsis left unset and the analysis excluded at least one point. Setmax_exclusions = 3to keep the current results, ormax_exclusions = 0to adopt the new default now; either stops the warning. The warning has the class"autospc_max_exclusions_default_warning"(#282).facet_stages(split_rows)is deprecated in favour ofsplit_at, which counts points in the analysed series - one point per subgroup, inxorder - rather than rows of the data as supplied. Where the data already holds one row per subgroup, inxorder, nothing changes. Supplyingsplit_rowswarns, and its value is taken assplit_at. It will be removed in 0.3.0.Setting
no_regrets = TRUEwithoverhanging_reversions = FALSEis deprecated, and will be an error in 0.3.0.no_regretsrequires consideration of overhanging reversions, so the combination does not make sense. It still warns and changesoverhanging_reversionsto TRUE.autospc(show_mr),facet_stages(show_mr)andautospc(write_table), deprecated since 0.1.0, still warn, and will be removed in 0.3.0.
New features
-
XbarS charts.
chart_type = "XbarS"draws an Xbar chart of subgroup means above an S chart of subgroup standard deviations, as specified e.g. in Provost and Murray, The Health Care Data Guide.chart_type = "Xbar"andchart_type = "S"draw either chart on its own, andfacet_stages()facets an XbarS request as its Xbar chart.- Data may have one row per measurement, with
ythe measurement, or rows that each summarise some measurements, withytheir mean,ntheir number and the new argumentstheir sample standard deviation. In either form, rows that share anxare combined into one subgroup, so e.g. withx = month, data with one row per practice per month gives one subgroup per month. Seevignette("data-requirements"). - As is standard, the Xbar centre line is the mean of the subgroup means weighted by subgroup size, the S centre line is the mean of the subgroup standard deviations weighted in the same way, and the limits of both charts vary with each subgroup’s size. The S chart’s lower limit is zero for subgroups of fewer than six.
- A subgroup of one is plotted on the Xbar chart and counts towards its centre line, but has no control limits. It has no standard deviation, so it is not plotted on the S chart.
- The two charts re-establish their limits independently, as the X and MR charts of an XMR chart do.
-
plot_chart = FALSEreturns the Xbar chart’s table with the S chart’s columns beside it:subgroup_s,s_cl,s_uclands_lcl. The Xbar table carriesn,sandsbar.
- Data may have one row per measurement, with
override_y_limtakes the lower end of the vertical axis as well. A single number still specifies the upper end. A vector of two numbers gives the lower and upper ends, andNAin either position leaves that end as the chart would have set it. The axis now zooms rather than clips, so nothing is dropped from the drawing: a limit or a centre line annotation outside the axis sits outside the panel. A range that would leave a data point outside the axis is an error.aggregation_na_rmcontrols what a missing (NA) observation does to the subgroup it is aggregated into.FALSE, the default, makes the whole subgroup missing, as before.TRUEdiscards the observation and forms the subgroup from the rest.Three package options, documented in
?autospc-package:autospc.rounded_constants,autospc.constrain_limitsandautospc.warn_missing_x.Arguments are checked.
title,subtitle,override_x_title,override_y_titleandlog_file_pathmust be a single string or NULL;r1_colandr2_colmust be a colour;x_date_formatmust hold at least one%code. A column named byx,yornthat is not in the data is named in the error along with the argument that named it, and a chart with noxsays so.
Bug fixes
facet_stages()accepts a paired chart type ("XMR"or"XbarS") held in a variable or given as an expression, e.g.chart_type = my_type. It previously failed with “No autospc_chart class for chart_type” (#302).A floating median is drawn on a series too short for control limits, and with
show_limits = FALSE.floating_median = "auto"no longer errors where a point in the median window is missing.A series shorter than
floating_median_nno longer warns “no non-missing arguments to max”, and draws no floating median.floating_median = "yes"warns when the series is too short for the median it asked for.facet_stages()no longer fails when no stage has enough points for control limits, or withshow_limits = FALSE, or when asked for a single stage. A split point beyond the end of the series is taken as the last point, with a warning, rather than repeating a stage.facet_stages(plot_chart = FALSE)always returns astagecolumn.In a faceted chart where some stages have limits and some do not, the points of a stage without limits are drawn black rather than the grey of an excluded point.
A chart drawn without control limits honours
x_break,x_date_formatandx_pad_end.The rows
extend_limits_toadds no longer change the type of thexandycolumns, and name the period they continue where the series ends with a subgroup that has no observation.plot_periodis missing on the rows before the first point and after the last, where it readNANA.Rows with no
xare excluded before the analysis rather than after, with a warning thatoptions(autospc.warn_missing_x = FALSE)turns off. One such row could previously add a subgroup of its own.The error raised when
extend_limits_tois not beyond the end of the data names the argument, and is raised before the chart is computed.The
month_startcolumn ofed_attendances_monthlyis the first day of each month; it was sometimes the last day of the month before. Charts drawn from this dataset shift by up to a day on the x axis. Its help page now lists its 7 columns correctly.
autospc 0.1.0
Lifecycle changes
Breaking changes
-
Seven columns of the table
autospc(plot_chart = FALSE)andfacet_stages(plot_chart = FALSE)return have been renamed from camelCase to snake_case, so that every column of the table is named the same way:Was Is now periodTypeperiod_typebreakPointbreak_pointaboveOrBelowClabove_or_below_clrunStartrun_startlimitChangelimit_changeperiodStartperiod_startplotPeriodplot_periodThe values are unchanged. Code that reads these columns by name — filtering on
periodType == "calculation", for one — needs the new name. The columns that were already snake_case (cl_change,cl_label,annotation_level,annotation_curvature,highlight,excluded) are unaffected, as arex,y,n,cl,ucl,lcland the moving range columnsmr,amr,urlandlrl. -
autospc(override_annotation_dist)andautospc(override_annotation_dist_P)are now defunct. They have warned since 0.0.0.9010; supplying either is now an error. Useupper_annotation_sfandlower_annotation_sfinstead — the equivalent scale factor is1 + 1/x, sooverride_annotation_dist = 10becomesupper_annotation_sf = 1.1, andlower_annotation_sfdefaults to its mirror image,2 - upper_annotation_sf. The two arguments remain in the signature so that the error can name their replacement, and will be removed in a later release.upper_annotation_sfandlower_annotation_sfapply to every chart type, so there is no replacement specific to P and P′ charts. -
create_SPC_auto_limits_table()is no longer exported. It was an internal step ofautospc()that had been made public without a documented reason, and holding it to a public interface was preventing the simplification of the package’s internals.autospc()does the same work and is the supported way to do it. For the results as data rather than a plot, useautospc(plot_chart = FALSE), which returns the same limits, rule breaks and period boundaries with the additional columns needed for plotting.If you were calling
create_SPC_auto_limits_table()directly andautospc(plot_chart = FALSE)does not meet your needs, please open an issue at https://github.com/HorridTom/autospc/issues — we are happy to help you move across.
Deprecations
-
autospc(write_table)is deprecated, and no longer writes a file. Save the results yourself instead:autospc(plot_chart = FALSE)returns them as a data frame, andas.data.frame()on a chart does the same. This is more flexible, giving you the choice of what type of file, how to save it, where to save it, etc.Note that there was also a bug that meant the feature did not work:
write_table = TRUEfailed. Supplying the argument now warns, and returns the results asplot_chart = FALSEwould. -
autospc(show_mr)is deprecated. Usechart_typeinstead:chart_type = "X"draws the X chart on its own, which is whatshow_mr = FALSEdid, andchart_type = "XMR"draws the pair. Supplyingshow_mrstill works and still does what it did, but now warns.Note that the caption names the chart type, so a chart drawn with
chart_type = "X"is captioned “X Shewhart Chart” where the same chart drawn withchart_type = "XMR", show_mr = FALSEwas captioned “XMR Shewhart Chart”. facet_stages(show_mr)is deprecated for the same reason.facet_stages()has never drawn the moving range chart, so anXMRrequest is now faceted as anXchart — including its caption, which changes from “XMR Shewhart Chart” to “X Shewhart Chart”. Nothing else about the chart changes.
Other changes
A chart has no x axis title unless you give one. The default was
"Day", whatever the x column held, so a chart of monthly or weekly data was labelled “Day” as well. Useoverride_x_titlefor a title of your own. The y axis is unchanged: where you give nooverride_y_titleit still takes one from the chart type.chart_type = "X"draws the X chart on its own, without the moving range chart beneath it. It gives the same result aschart_type = "XMR"withshow_mr = FALSE.-
autospc()returns a plot object that is still a ggplot — printing,ggsave()and adding ggplot2 layers all work as before — and additionally carries the analysed chart it was drawn from.as.data.frame()on it returns the analysis.An XmR chart carries both halves of the pair, the X chart first and the moving range chart second.
as.data.frame()on one returns them joined side by side, with the moving range and its limits asmr,amr,urlandlrl— the same shapeautospc(plot_chart = FALSE)returns.facet_stages()returns the same kind of object, carrying one analysed chart per facet in stage order. Wheresplit_rowsis named, the charts take those names.as.data.frame()on one stacks the facets, withstagesaying which each row came from — the same columnfacet_stages(plot_chart = FALSE)returns. A
titleorsubtitlecolumn in the data is no longer repeated over the moving range chart of an XmR pair. The pair is one chart in two panels, so its title is drawn once, above the X chart. A title given as an argument was already drawn once; this makes the two agree.autospc(plot_chart = FALSE, show_limits = FALSE)now returns the four columns describing the periods —limit_change,period_start,plot_periodandcl_change— which it previously returned only whenshow_limitswasTRUE.-
autospc(plot_chart = FALSE)andfacet_stages(plot_chart = FALSE)always return a plain data frame. Previously the class depended on the chart type: given a data frame, C and C′ charts returned a tibble and the other chart types returned a data frame; given a tibble, every chart type returned a tibble. The same now applies to the frames a chart object carries — the analysis in$result$tableand the tables in$history.$data_original, which is the data as you passed it, is unchanged and keeps its class.Add
tibble::as_tibble()to the result if you want a tibble. The analysed columns keep the type they were supplied with.
y, andnfor a P or P′ chart, were coerced to double inside the algorithm, so integer counts came back as doubles; they now come back as integers. The limits —cl,uclandlcl— are doubles as before, whatever the counts they were computed from. Values are unchanged.Columns other than those a chart uses are now dropped consistently. Previously the aggregation step was skipped entirely when no
xvalue was repeated, so extra columns survived into the output for a series with one row per subgroup and were dropped for one without. They are now dropped in both cases.autospc(keep_candidate_tables)is a new argument,FALSEby default. The algorithm considers a candidate calculation period at each point where it might re-establish the limits, and records each one it forms. Setting this toTRUEadditionally records, for each candidate, the full table of limits it would have produced. It is off by default because those tables are several times the size of everything else the chart holds: for a 600-point chart that re-establishes its limits nine times, the chart object measured 111 KB with the default and 534 KB withkeep_candidate_tables = TRUE.The default values of
period_minandmax_exclusionsare now the integers21Land3L, where they were the doubles21and3. Both are counts of data points. Passing a double still works.A rounding warning is no longer given for data that is then rejected. A P or P′ chart given a numerator with fractional values and a denominator of the wrong type warned that it was rounding the numerator before erroring on the denominator; it now raises the error without the warning.
Bug fixes
autospc()no longer warns where a column namedx,yornis present in the data and the matching argument is also given (#85). The warning said that the column named in the argument would be used, so it told the caller only that the package had done as it was asked. It warned even where the argument named the same column —x = xon data whose column is already calledx— which is the case the issue reported. There were three of these, one each forx,yandn. All three have gone, including where the argument names a different column from the one already calledx: the column named in the argument is the one used, and$data_originalholds every column exactly as it was passed.-
log_file_pathnow writes one file per call, holding every chart the call analysed, with achartcolumn saying which each entry came from. An XmR run wrote the file twice — once for the X chart and once for the moving range chart, the second overwriting the first — so the X chart’s log was lost. A faceted run did the same once per facet, leaving only the last stage. For an XmR pairchartholds the chart type,"X"or"MR"; for a faceted chart it holds the stage, named fromsplit_rowswhere it has names and numbered where it does not. A run of a single chart writes the same shape, with one value in that column.The log written to file is also a plain data frame now, where it was a rowwise tibble.
The console log of the X chart of an XmR pair is headed
Xrather thanXMR. It is the X chart’s log; the moving range chart’s log follows it, headedMR.Setting
no_regrets = TRUEwithoverhanging_reversions = FALSEwarns once per call. An XmR run warned twice, and a faceted run once per facet, because the check ran once per chart constructed.An x column of a type the chart cannot be drawn against — anything other than
Date,POSIXct, numeric or integer — warns once per call. A faceted run warned once per facet and once more for the series as a whole.Data holding a column called
x,yornno longer prevents a different column being used for that argument.autospc(data, x = month, y = count), wheredataalso has a column calledx, failed withNames must be unique; the column named in the argument is now used and the column calledxis dropped, along with the other columns the analysis does not use. The data as supplied is unaffected.facet_stages()warned in the same situation and then failed the same way; it now behaves asautospc()does.facet_stages()now labels its axes. It resolved the axis titles and then never passed them to the drawing, so a faceted chart had no axis labels at all, where the same data throughautospc()was labelled. Atitleorsubtitlecolumn in the data was dropped the same way and now reaches the chart. Titles given as arguments were unaffected and still win.facet_stages()without achart_typenow says so. It failed withargument is of length zerobefore reaching the check that names the argument and lists the chart types available.facet_stages()now uses the same annotation positioning asautospc()on R below 4.3.basic_annotationsdefaults togetRversion() < "4.3.0"inautospc(), but the faceted path never passed the default on, so a faceted chart fell back to the positioning that needs ggrepel and ggpp. On R 4.3 and later nothing changes.chart_type = "XMR"no longer fails whenautospc()is called from a wrapper that forwards its arguments —function(...) autospc(...)— which raised'...' used in an incorrect context. The XmR pair was the only chart type that re-invokedautospc()through the call it had been given, and it no longer does: both halves are analysed directly.The series is now sorted by
xbefore limits are calculated. The algorithm works through the points in order, so data supplied out ofxorder produced different limits from the same data supplied in order, and was plotted against a scrambled series. Charts that aggregate overx— C, C′, P and P′ — were usually protected by the aggregation step, which sorts as a side effect; X and MR charts were affected whatever the data. Results will change for any series that was not already inxorder.P and P′ charts accepting individual binary observations no longer fail when every subgroup holds exactly one observation. The run stopped with
object 'n' not found, because the denominator is materialised during aggregation and aggregation was skipped when noxvalue was repeated. Note that such a series is degenerate — every proportion is 0% or 100%.
autospc 0.0.0.9040
Lifecycle changes
Breaking changes
-
plot_auto_SPC()has been renamed toautospc(). Thereforeplot_auto_SPC()is now deprecated. Many of this function’s arguments have also been renamed, in line with the Tidyverse style guide. The table below provides details of all name changes implemented in this change.
| What | Before | After | Change |
|---|---|---|---|
| Version number | 0.0.0.9039 | 0.0.0.9040 | Yes |
| Function | plot_auto_SPC() | autospc() | Yes |
| Argument | df | data | Yes |
| Argument | x | x | No |
| Argument | y | y | No |
| Argument | n | n | No |
| Argument | chartType | chart_type | Yes |
| Argument group | ## Algorithm Parameters | ## Algorithm Parameters | No |
| Argument | periodMin | period_min | Yes |
| Argument | baseline | baseline_length | Yes |
| Argument | runRuleLength | shift_rule_threshold | Yes |
| Argument | noRecals | baseline_only | Yes |
| Argument | recalEveryShift | establish_every_shift | Yes |
| Argument | noRegrets | no_regrets | Yes |
| Argument | overhangingReversions | overhanging_reversions | Yes |
| Argument group | ## SPC Parameters | ## SPC Parameters | No |
| Argument | maxNoOfExclusions | max_exclusions | Yes |
| Argument | highlightExclusions | highlight_exclusions | Yes |
| Argument | mr_screen_max_loops | mr_screen_max_loops | No |
| Argument | rule2Tolerance | centre_line_tolerance | Yes |
| Argument | floatingMedian | floating_median | Yes |
| Argument | floatingMedian_n | floating_median_n | Yes |
| Argument group | ## Output Type | ## Output Type | No |
| Argument | plotChart | plot_chart | Yes |
| Argument | showLimits | show_limits | Yes |
| Argument | showMR | show_mr | Yes |
| Argument | writeTable | write_table | Yes |
| Argument | verbosity | verbosity | No |
| Argument | log_file_path | log_file_path | No |
| Argument group | ## Chart Appearance | ## Chart Appearance | No |
| Argument | title | title | No |
| Argument | subtitle | subtitle | No |
| Argument | use_caption | use_caption | No |
| Argument | override_x_title | override_x_title | No |
| Argument | override_y_title | override_y_title | No |
| Argument | override_y_lim | override_y_lim | No |
| Argument | x_break | x_break | No |
| Argument | x_date_format | x_date_format | No |
| Argument | x_pad_end | x_pad_end | No |
| Argument | extend_limits_to | extend_limits_to | No |
| Argument | r1_col | r1_col | No |
| Argument | r2_col | r2_col | No |
| Argument | point_size | point_size | No |
| Argument | line_width_sf | line_width_sf | No |
| Argument | includeAnnotations | include_annotations | Yes |
| Argument | basicAnnotations | basic_annotations | Yes |
| Argument | annotation_size | annotation_size | No |
| Argument | align_labels | align_labels | No |
| Argument | flip_labels | flip_labels | No |
| Argument | upper_annotation_sf | upper_annotation_sf | No |
| Argument | lower_annotation_sf | lower_annotation_sf | No |
| Argument | annotation_arrows | annotation_arrows | No |
| Argument | annotation_arrow_curve | annotation_arrow_curve | No |
| Argument | override_annotation_dist | override_annotation_dist | No |
| Argument | override_annotation_dist_P | override_annotation_dist_P | No |