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):datais in long format (one row per observation) and Office counts occurrences of eachxvalue.yis optional; when supplied, values are summed per category.aggregate = FALSE:datais already aggregated (one row per category) andyis the count/value column.
See also
Examples
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)
#> Warning: Calling `add_slide()` without specifying a `layout` is deprecated.
#> Please pass a `layout` or use `layout_default()` to set a default.
#> => I will now continue with the former `layout` default "Title and Content" for backwards compatibility...
doc <- ph_with(doc, pa, location = ph_location_fullsize())
print(doc, target = tempfile(fileext = ".pptx"))
