

   list {base}                                  R Documentation

   LLiissttss ---- GGeenneerriicc aanndd DDootttteedd PPaaiirrss

   DDeessccrriippttiioonn::

        Functions to construct, coerce and check for all kinds
        of R lists.

   UUssaaggee::

        list(...)
        pairlist(...)

        as.list(x)
        as.list.default(x)
        as.pairlist(x)

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

        alist(...)

   DDeettaaiillss::

        Since version 0.63, most lists in R internally are
        Generic Vectors, whereas traditional dotted pair lists
        (as in LISP) are still available.

        The arguments to `list' or `pairlist' are of the form
        `value' or `tag=value'.  The functions return a list
        composed of its arguments with each value either tagged
        or untagged, depending on how the argument was speci-
        fied.

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

        `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.

        `is.list' returns `TRUE' iff its argument is a `list'
        or a `pairlist' of `length'> 0, whereas `is.pairlist'
        only returns `TRUE' in the latter case.

        An empty pairlist, `pairlist()' is the same as `NULL'.
        This is different from `list()'.

   SSeeee AAllssoo::

        `vector(., mode="list")', `c', for concatenation; `for-
        mals'.

   EExxaammpplleess::

        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
        str(al)

        str(pl <- as.pairlist(ps.options()))

        ## These are all TRUE:
        is.list(pl) && is.pairlist(pl)
        !is.null(list())
        is.null(pairlist())
        !is.list(NULL)
        is.pairlist(pairlist())
        is.null(as.pairlist(list()))
        is.null(as.pairlist(NULL))

