\HeaderA{packet.panel.default}{Associating Packets with Panels}{packet.panel.default}
\keyword{dplot}{packet.panel.default}
\begin{Description}\relax
When a \code{"trellis"} object is plotted, panels are always drawn in
an order such that columns vary the fastest, then rows and then pages.
An optional function can be specified that determines, given the
column, row and page and other relevant information, the packet (if
any) which should be used in that panel.  The function documented here
implements the default behaviour, which is to match panel order with
packet order, determined by varying the first conditioning variable
the fastest, then the second, and so on.  This matching is performed
after any reordering and/or permutation of the conditioning variables.
\end{Description}
\begin{Usage}
\begin{verbatim}

packet.panel.default(layout, condlevels, page, row, column,
                     skip, all.pages.skip = TRUE) 

\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{layout}] the \code{layout} argument in high level functions,
suitably standardized.  
\item[\code{condlevels}] a list of levels of conditioning variables, after
relevant permutations and/or reordering of levels 
\item[\code{page, row, column}] the location of the panel in the coordinate
system of pages, rows and columns.  
\item[\code{skip}] the \code{skip} argument in high level functions 
\item[\code{all.pages.skip}] whether \code{skip} should be replicated over
all pages.  If \code{FALSE}, \code{skip} will be replicated to be
only as long as the number of positions on a page, and that
template will be used for all pages. 
\end{ldescription}
\end{Arguments}
\begin{Value}
A suitable combination of levels of the conditioning variables in the
form of a numeric vector as long as the number of conditioning
variables, with each element an integer indexing the levels of the
corresponding variable.  Specifically, if the return value is
\code{p}, then the \code{i}-th conditioning variable will have level
\code{condlevels[[i]][p[i]]}.
\end{Value}
\begin{Author}\relax
Deepayan Sarkar \email{Deepayan.Sarkar@R-project.org}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{Lattice}{Lattice}}, \code{\LinkA{xyplot}{xyplot}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

packet.panel.page <- function(n)
{
    ## returns a function that when used as the 'packet.panel'
    ## argument in print.trellis plots page number 'n' only
    function(layout, page, ...) {
        stopifnot(layout[3] == 1)
        packet.panel.default(layout = layout, page = n, ...)
    }
}

data(mtcars)
HP <- equal.count(mtcars$hp, 6)
p <- 
    xyplot(mpg ~ disp | HP * factor(cyl),
           mtcars, layout = c(0, 6, 1))

print(p, packet.panel = packet.panel.page(1))
print(p, packet.panel = packet.panel.page(2))

\end{ExampleCode}
\end{Examples}

