List Objects

DESCRIPTION:
Creates or tests for lists (objects with mode "list").

USAGE:
list(...)
is.list(x)
as.list(x)

OPTIONAL ARGUMENTS:
...:
any arguments, with any names.

x:
any S-PLUS object.

VALUE:
list returns an object of mode list, with as many components as there are arguments. The individual arguments become the components of the list, and the argument names, if any, are the corresponding elements of the names attribute of the list.

is.list returns TRUE if x has mode "list", and FALSE otherwise.

as.list returns x if x is a simple object of mode "list", and otherwise a list object of the same length as x. If x is an atomic object, the elements of the list will be objects of length 1, containing the individual elements of x. If x is a recursive object, its elements will be unchanged. Attributes will be deleted.


DETAILS:
The constructor function for lists is different from those for atomic modes, which take the desired length as an argument. To generate a list of length 10 when you don't initially know what the elements should be, use: vector("list", 10) Lists are simple objects (see vector) when they have no attributes, other than names. It is possible, for example, to have a matrix, array or time series of mode list.

Both the as.list and is.list functions are generic; currently there are no methods written for either of them.


SEE ALSO:
c , unlist , mode , vector .

EXAMPLES:
list(original=x, square=x^2)

as.list(1:10) # ten integer components list (1:10) # one component

# the arguments can themselves be lists # and some components can be named while others are not list(1:10, col="brown", list(5:15, 3:7, 34:39))