Learn R Programming

yamlet (version 1.2.1)

unnest: Collapse Uninformative Levels

Description

Each element of a list that is itself a list and does not have a name but has exactly one element that DOES have a name should become that element and have that name (recursively, from depth). Collapses uninformative levels of nested lists. Formerly used in as_yam; now superceded by parsimonious.list.

Usage

unnest(x, ...)

Value

named list

Arguments

x

object

See Also

Other unnest: unnest.default(), unnest.list()

Examples

Run this code

# yaml.load reads this as a list of two un-named lists whose elements are named.
str(yaml::yaml.load('[foo: 1, bar: 3]'))

# yamlet treats it as a list of two named integers.
str(unnest(yaml::yaml.load('[foo: 1, bar: 3]')))

Run the code above in your browser using DataLab