\Header{list}{Lists -- Generic and Dotted Pairs}
\alias{alist}{list}
\alias{as.list}{list}
\methalias{as.list.data.frame}{list}
\methalias{as.list.default}{list}
\methalias{as.list.environment}{list}
\alias{as.pairlist}{list}
\alias{is.list}{list}
\alias{is.pairlist}{list}
\alias{pairlist}{list}
\keyword{list}{list}
\keyword{manip}{list}
\begin{Description}\relax
Functions to construct, coerce and check for all kinds of \R{} lists.
\end{Description}
\begin{Usage}
\begin{verbatim}
list(...)
pairlist(...)

as.list(x, ...)
as.pairlist(x)
as.list.environment(x, all.names=FALSE, ...)

is.list(x)
is.pairlist(x)

alist(...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] objects.
\item[\code{x}] object to be coerced or tested.
\item[\code{all.names}] a logical indicating whether to copy all values in as.list.environment
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Most lists in \R{} internally are \emph{Generic
Vectors}, whereas traditional \emph{dotted pair} lists (as in LISP)
are still available.

The arguments to \code{list} or \code{pairlist} are of the form
\code{value} or \code{tag=value}.
The functions return a list composed of its arguments
with each value either tagged or untagged,
depending on how the argument was specified.

\code{alist} is like \code{list}, except in the handling of tagged
arguments with no value. These are handled as if they described
function arguments with no default (cf. \code{\Link{formals}}), whereas
\code{list} simply ignores them.

\code{as.list} attempts to coerce its argument to list type.
For functions, this returns the concatenation of the list of formals
arguments and the function body. For expressions, the list of
constituent calls is returned.

\code{is.list} returns \code{TRUE} iff its argument
is a \code{list} \emph{or} a \code{pairlist} of \code{length}\eqn{> 0}{},
whereas \code{is.pairlist} only returns \code{TRUE} in the latter case.

\code{is.list} and \code{is.pairlist} are generic: you can write
methods to handle specific classes of objects, see \link{InternalMethods}.

\code{as.list.environment} copies the named values from an environment to a list. The 
user can request that all named objects are copied (normally names that begin with a dot 
are not). The output is not sorted and no parent environments are searched.

An empty pairlist, \code{pairlist()} is the same as \code{NULL}.  This
is different from \code{list()}.
\end{Details}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\Link{vector}(., mode="list")}, \code{\Link{c}}, for concatenation;
\code{\Link{formals}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(cars)
# create a plotting structure
pts <- list(x=cars[,1], y=cars[,2])
plot(pts)

# Argument lists
f <- function()x
# Note the specification of a "..." argument:
formals(f) <- al <- alist(x=, y=2, ...=)
f
al

##environment->list coercion

e1 <- new.env()
e1$a <- 10
e1$b <- 20
as.list(e1)
\end{ExampleCode}
\end{Examples}

