list                  package:base                  R Documentation

_L_i_s_t_s - _G_e_n_e_r_i_c _a_n_d _D_o_t_t_e_d _P_a_i_r_s

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

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

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

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

     alist(...)

_A_r_g_u_m_e_n_t_s:

     ...: objects.

       x: object to be coerced or tested.

all.names: a logical indicating whether to copy all values in
          as.list.environment

_D_e_t_a_i_l_s:

     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 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' iff its argument is a 'list' _or_ a
     'pairlist' of 'length'> 0, whereas 'is.pairlist' only returns
     'TRUE' in the latter case.

     'is.list' and 'is.pairlist' are generic: you can write methods to
     handle specific classes of objects, see InternalMethods.

     '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, 'pairlist()' is the same as 'NULL'.  This is
     different from 'list()'.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_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
     al

     ##environment->list coercion

     e1 <- new.env()
     e1$a <- 10
     e1$b <- 20
     as.list(e1)

