unlist(data, recursive=T, use.names=T)
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=T) to enforce such rules.
c(..., recursive=T) is equivalent to unlist(list(...), recursive=T).
This is a generic function; there are currently no methods for it.
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))# build a vector of variable-length results where fun returns a list x <- vector("list", n) for(i in 1:n) x[[i]] <- fun(i) x <- unlist(x, recursive=F)
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