Adds native 'Microsoft Office' error bars to one or more series of a bar, line or scatter chart. The error bars are rendered by the host application (PowerPoint, Word or Excel) and remain editable.
This exposes the native c:errBars chart element and supports fixed
value, percentage, standard deviation, standard error and fully custom
(per-point) error amounts, in the plus, minus or both directions.
Arguments
- x
an
ms_chartobject created withms_barchart(),ms_linechart()orms_scatterchart().- series
character vector of series names the error bars should be added to. When
NULL(default), error bars are added to every series.- type
the error amount type, one of
"fixedVal"(a fixed amount),"percentage"(a percentage of each value),"stdDev"(a multiple of the standard deviation),"stdErr"(the standard error) or"cust"(custom per-point amounts supplied viaplus/minus).- value
a single numeric amount used when
typeis"fixedVal","percentage"or"stdDev". Ignored for"stdErr"and"cust".- plus, minus
numeric vectors of custom error amounts (one per data point) used when
type = "cust".plusis the positive error andminusthe negative error. Recycled to the number of points if length 1.- direction
the error bar direction, one of
"both","plus"or"minus".- errdir
the axis the error bars apply to,
"y"(default) or"x"."x"is only valid forms_scatterchart().- end_cap
if
TRUE(default), draw the T-shaped end cap.- line
an
officer::fp_border()describing the error bar colour, width and dash style. WhenNULL, Office uses its default styling.
Examples
library(officer)
dat <- data.frame(
cat = c("A", "B", "C", "D"),
val = c(4, 7, 5, 9)
)
bc <- ms_barchart(data = dat, x = "cat", y = "val")
bc <- chart_error_bars(bc, type = "percentage", value = 10)
