% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ms_paretochart.R
\name{ms_paretochart}
\alias{ms_paretochart}
\title{Pareto chart object}
\usage{
ms_paretochart(data, x, y = NULL, aggregate = TRUE)
}
\arguments{
\item{data}{a data.frame.}

\item{x}{category column name.}

\item{y}{optional numeric column. With \code{aggregate=TRUE} and \code{y=NULL},
each row counts as 1.}

\item{aggregate}{logical, see Description. Default TRUE.}
}
\value{
An \code{ms_chart} object (subclass \code{ms_paretochart}).
}
\description{
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:
\itemize{
\item \code{aggregate = TRUE} (default): \code{data} is in long format (one row per
observation) and Office counts occurrences of each \code{x} value.
\code{y} is optional; when supplied, values are summed per category.
\item \code{aggregate = FALSE}: \code{data} is already aggregated (one row per
category) and \code{y} is the count/value column.
}
}
\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)
doc <- ph_with(doc, pa, location = ph_location_fullsize())
print(doc, target = tempfile(fileext = ".pptx"))
}
\seealso{
\code{\link[=chart_labels]{chart_labels()}}

Other 'Office' chart objects:
\code{\link[=ms_areachart]{ms_areachart()}},
\code{\link[=ms_barchart]{ms_barchart()}},
\code{\link[=ms_boxplotchart]{ms_boxplotchart()}},
\code{\link[=ms_bubblechart]{ms_bubblechart()}},
\code{\link[=ms_chart_combine]{ms_chart_combine()}},
\code{\link[=ms_funnelchart]{ms_funnelchart()}},
\code{\link[=ms_histogramchart]{ms_histogramchart()}},
\code{\link[=ms_linechart]{ms_linechart()}},
\code{\link[=ms_piechart]{ms_piechart()}},
\code{\link[=ms_radarchart]{ms_radarchart()}},
\code{\link[=ms_scatterchart]{ms_scatterchart()}},
\code{\link[=ms_stockchart]{ms_stockchart()}},
\code{\link[=ms_sunburstchart]{ms_sunburstchart()}},
\code{\link[=ms_treemapchart]{ms_treemapchart()}},
\code{\link[=ms_waterfallchart]{ms_waterfallchart()}}
}
\concept{'Office' chart objects}
