list.flatten: Flatten a nested list to a one-level list

View source: R/list.flatten.R

list.flattenR Documentation

Flatten a nested list to a one-level list

Description

Flatten a nested list to a one-level list

Usage

list.flatten(x, use.names = TRUE, classes = "ANY")

Arguments

x

list

use.names

logical. Should the names of x be kept?

classes

A character vector of class names, or "ANY" to match any class.

Details

The function is essentially a slightly modified version of flatten2 provided by Tommy at stackoverflow.com who has full credit of the implementation of this function.

Author(s)

Tommy

Examples

p <- list(a=1,b=list(b1=2,b2=3),c=list(c1=list(c11='a',c12='x'),c2=3))
list.flatten(p)

p <- list(a=1,b=list(x="a",y="b",z=10))
list.flatten(p, classes = "numeric")
list.flatten(p, classes = "character")

renkun-ken/rlist documentation built on March 16, 2023, 8:25 p.m.