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) # a vector of length 12
unlist(lista, recursive=F)
# a list of length 8 with final components b.b1 and b.b2
# equivalent to list(1, 2, 3, a1=5, a2=6, a3=7, 
# b.b1=12:14, b.b2=c(23,25,28))
x <- list(A=1,B=c(a=2,b=3,4),list(d=5,6))  # names construction
unlist(x)
#  A B.a B.b B3 d
#  1   2   3  4 5 6
Package base version 4.0.0-28
Package Index