\HeaderA{gggroup}{Grob function: groups}{gggroup}
\keyword{hplot}{gggroup}
\begin{Description}\relax
Create multiple of grobs based on id aesthetic.
\end{Description}
\begin{Usage}
\begin{verbatim}gggroup(plot = .PLOT, aesthetics=list(), ..., data=NULL)\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{plot}] the plot object to modify
\item[\code{aesthetics}] named list of aesthetic mappings, see details for more information
\item[\code{...}] other options, see details for more information
\item[\code{data}] data source, if not specified the plot default will be used
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This grob function provides a general means of creating
multiple grobs based on groups in the data.  This is useful
if you want to fit a separate smoother for each group in the data.

You will need an id variable in your aesthetics list with determines
how the data is broken down.

Aesthetic mappings that this grob function understands:

\Itemize{
\item \code{x}:x position (required)
\item \code{y}:y position (required)
\item \code{id}:
\item any other grobs used by the grob function you choose
}

These can be specified in the plot defaults (see \code{\LinkA{ggplot}{ggplot}}) or
in the \code{aesthetics} argument.  If you want to modify the position
of the points or any axis options, you will need to add a position scale to
the plot.  These functions start with \code{ps}, eg.
\code{\LinkA{pscontinuous}{pscontinuous}} or \code{\LinkA{pscategorical}{pscategorical}}

Other options:

\Itemize{
\item \code{grob}:grob function to use for subgroups
\item anything else used by the grob function you choose
}
\end{Details}
\begin{Author}\relax
Hadley Wickham <h.wickham@gmail.com>
\end{Author}
\begin{Examples}
\begin{ExampleCode}p <- ggplot(mtcars, aesthetics=list(y=wt, x=qsec, id=cyl, colour=cyl))
gggroup(p)
gggroup(p, grob="density")
gggroup(p, grob="histogram", aes=list(fill=cyl))
gggroup(ggpoint(p), grob="smooth", se=FALSE, span=1)
gggroup(ggpoint(p), aes=list(id=cyl, size=cyl), grob="smooth", span=1)\end{ExampleCode}
\end{Examples}

