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:
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.) 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.1-7
Package Index