View source: R/ms_paretochart.R
| ms_paretochart | R Documentation |
Creation of a Pareto chart object that can be inserted in a 'Microsoft' document. Pareto charts use the chartEx pipeline (Office 2016+); older versions of 'Microsoft Office' will display a fallback placeholder.
Office draws columns sorted by descending count plus a cumulative line on a secondary percentage axis.
Two input modes are supported:
aggregate = TRUE (default): data is in long format (one row per
observation) and Office counts occurrences of each x value.
y is optional; when supplied, values are summed per category.
aggregate = FALSE: data is already aggregated (one row per
category) and y is the count/value column.
ms_paretochart(data, x, y = NULL, aggregate = TRUE)
data |
a data.frame. |
x |
category column name. |
y |
optional numeric column. With |
aggregate |
logical, see Description. Default TRUE. |
An ms_chart object (subclass ms_paretochart).
chart_labels()
Other 'Office' chart objects:
ms_areachart(),
ms_barchart(),
ms_boxplotchart(),
ms_bubblechart(),
ms_chart_combine(),
ms_funnelchart(),
ms_histogramchart(),
ms_linechart(),
ms_piechart(),
ms_radarchart(),
ms_scatterchart(),
ms_stockchart(),
ms_sunburstchart(),
ms_treemapchart(),
ms_waterfallchart()
library(officer)
set.seed(1)
dat <- data.frame(
defect = sample(c("A", "B", "C", "D"), 50, replace = TRUE,
prob = c(0.5, 0.25, 0.15, 0.1))
)
pa <- ms_paretochart(dat, x = "defect")
doc <- read_pptx()
doc <- add_slide(doc)
doc <- ph_with(doc, pa, location = ph_location_fullsize())
print(doc, target = tempfile(fileext = ".pptx"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.