Lists

Usage

list(...)
as.list(x)
is.list(x)
alist(...)

Description

The arguments to list are of the form value or tag=value. The function returns a list composed of its arguments with each value either tagged or untagged, depending on how the argument was specified.

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 if its argument is a list and FALSE otherwise.

To create an empty list, it is necessary to use the function vector with a mode of "list".

See Also

vector(., mode="list"), c, for concatenation; formals.

Examples

data(cars)
# create a plotting structure
pts <- list(x=cars[,1], y=cars[,2])
plot(pts)

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


[Package Contents]