unlist
Simplify the Structure of a List

### Description

Returns a vector or a list that is the result of simplifying the recursive structure of the input list.

### Usage

    unlist(x, recursive = TRUE, use.names = TRUE)

### Arguments

x | a vector. Typically a list.
recursive | a logical value. If TRUE (the default), the unlisting should be done recursively.
use.names | a logical value. If TRUE (the default), the function uses the rule described in the Details section to construct a names attribute for the result. If FALSE, the resulting object does not have a names attribute.

### Details

If use.names is TRUE, names are built from the component names according to the following rules:

- If i is a component of x, and iname represents its corresponding name, then, in the unlisted version, i has names that are made by pasting iname and the names attribute of i, with separator "." (assuming that both strings are non-empty).
- If iname is the empty string (that is, i has no component name) just the names attribute of i is used, if it exists.
- If iname is not empty, but i has no names attribute, then iname is used, followed by the index of the corresponding element in i. (It has no separating "." in this case, and if i has length 1, the redundant "1" is not added.)
- If recursive is TRUE, the rule above is applied, bottom up, recursively. The same rule applies to names created by the c() function, with the equivalence shown below. The algorithm does not enforce rules on the names, such as uniqueness or that every name be non-empty. Use names(x) <- make.names(names(x), unique=TRUE) to enforce such rules.
- c(..., recursive=TRUE) is equivalent to unlist(list(...), recursive=TRUE).

Value
returns a vector or list created by combining the components of x. (See Help for the c function for more information on combining components.)

- If x is atomic or an expression, x is returned unmodified.
- If x is a list of factors, the factors are combined into one.
- If recursive is TRUE, each component of x is unlisted (with recursive=TRUE) before it is combined.

Using the idea of x as a tree, calling unlist with recursive=TRUE produces a vector of all the leaves. The mode of the result is the most general of all the modes of the components of x, or of the leaves of x if recursive is TRUE.
See Also
c, list.
Examples

    lista <- list(1:3, a=5:7, b=list(b1=12:14, b2=c(23, 25, 28)))
    unlist(lista) # numeric vector of length 12
    str(unlist(lista, recursive=FALSE)) # list of length 8
    unlist(list(A=1,B=c(a=2,b=3,4),list(d=5,6)))  # names construction
    unlist(list(factor(c("A","C")), factor(c("D","B","A")))) # factor

Package base version 6.1.5-18
Package Index