Generate interactive SPC chart
spc.RdGenerate interactive SPC chart
Usage
spc(
data,
keys,
numerators,
denominators,
groupings,
indicators = NULL,
xbar_sds,
tooltips = NULL,
labels = NULL,
aggregations = NULL,
title = NULL,
canvas_settings = NULL,
spc_settings = NULL,
outlier_settings = NULL,
nhs_icon_settings = NULL,
scatter_settings = NULL,
line_settings = NULL,
x_axis_settings = NULL,
y_axis_settings = NULL,
date_settings = NULL,
label_settings = NULL,
summary_table_settings = NULL,
tooltip_settings = NULL,
width = NULL,
height = NULL,
elementId = NULL,
return_objs = c("html_plot", "static_plot", "limits")
)Arguments
- data
A data frame containing the data for the chart.
- keys
A vector or column name representing the categories (x-axis) of the chart.
- numerators
A numeric vector or column name representing the numerators for each category.
- denominators
A numeric vector or column name representing the denominators for each category. Optional for
i,i_m,i_mm,runandmrcharts, which then plot numerators divided by denominators; an indicator whose denominators are all missing plots its numerators.- groupings
A vector or column name representing the grouping for each category.
- indicators
A vector or list of vectors representing indicator categories for the summary table. Factor indicators are ordered by their levels, and others by value.
- xbar_sds
A numeric vector or column name representing the x-bar and standard deviation values for each category.
- tooltips
A vector or column name, or a list of them, representing additional tooltips for each category. Each is labelled by its name in the list, or else by the expression supplied.
NULLfor none. Limits include them with their R types, reduced within each key byaggregations$tooltips.- labels
A vector or column name representing the labels for each category.
NULLfor none.- aggregations
A list of aggregation function names for each field if multiple values are provided for each key. Valid options are:
"first": returns the first non-missing value"last": returns the last non-missing value"sum": returns the sum of values"mean": returns the mean of values"min": returns the minimum value"max": returns the maximum value"median": returns the median value"count": returns the count of non-missing values
Defaults to
"sum"for numerators and denominators, and"first"otherwise. Every aggregation ignores missing values; an all-missing group has a count of 0 and is otherwise missing. Numerators and denominators are aggregated independently.- title
Optional title to be added to the top of the chart. It can be a character string for the title text only, or a list with the following options:
text: Title text (default: NULL)font_size: Font size of the title (default: "16px")font_weight: Font weight of the title (default: "bold")font_family: Font family of the title (default: "'Arial', sans-serif")x: Horizontal (x) position of the title as a percentage (default: "50%")y: Vertical (y) position of the title in pixels (default: 5)text_anchor: Text anchor of the title (default: "middle")dominant_baseline: Dominant baseline of the title (default: "hanging")subtitle: Subtitle text, drawn below the title (default: NULL)subtitle_font_size: Font size of the subtitle (default: "12px")subtitle_font_weight: Font weight of the subtitle (default: "normal")
- canvas_settings
Optional list of settings for the canvas, see
spc_default_settings('canvas')for valid options.- spc_settings
Optional list of settings for the SPC chart, see
spc_default_settings('spc')for valid options.- outlier_settings
Optional list of settings for outliers, see
spc_default_settings('outliers')for valid options. Detection switches use the first valid outlier settings after sorting and aggregating keys, separately for each indicator, for both plots and limits.- nhs_icon_settings
Optional list of settings for NHS icons, see
spc_default_settings('nhs_icons')for valid options.- scatter_settings
Optional list of settings for scatter points, see
spc_default_settings('scatter')for valid options.- line_settings
Optional list of settings for lines, see
spc_default_settings('lines')for valid options.- x_axis_settings
Optional list of settings for the x-axis, see
spc_default_settings('x_axis')for valid options.- y_axis_settings
Optional list of settings for the y-axis, see
spc_default_settings('y_axis')for valid options.- date_settings
Optional list of settings for dates, see
spc_default_settings('dates')for valid options.- label_settings
Optional list of settings for labels, see
spc_default_settings('labels')for valid options.- summary_table_settings
Optional list of settings for the summary table, see
spc_default_settings('summary_table')for valid options. A table shown byshow_tablehas no static plot.- tooltip_settings
Optional list of settings for tooltips, see
spc_default_settings('tooltips')for valid options.- width
Optional width of the chart in pixels. If NULL (default), the chart will fill the width of its container.
- height
Optional height of the chart in pixels. If NULL (default), the chart will fill the height of its container.
- elementId
Optional HTML element ID for the chart.
- return_objs
Character vector of object types to return. Valid values are:
"html_plot": Interactivehtmlwidgetsplot"static_plot": Non-interactive SVG plot"limits": Calculated control limits
When
indicatorsare supplied, orsummary_table_settingssetsshow_table,"static_plot"is omitted by default.
Value
An object of class controlchart containing the
interactive plot, static plot, limits, and a function to save the plot.
Limits are a flat data frame. Supplied indicator columns are included by name.
xbar and s limits include each group's size as denominator.
The key column is named after the keys expression and retains its type.
It is duplicated as key for compatibility.
Tooltip columns are included by name.
Empty input returns empty limits with typed keys and tooltips, without plots.