unnest: Collapse Uninformative Levels

View source: R/yamlet.R

unnestR Documentation

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, ...)

Arguments

x

object

Value

named list

See Also

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

Examples


# 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]')))

bergsmat/yamlet documentation built on Feb. 18, 2024, 5:50 a.m.