list_depth: Get the depth of a list

Description Usage Arguments Value See Also Examples

Description

Gets the depth of a list (at its deepest point).

Usage

1
list_depth(l, prune_empty_elts = FALSE)

Arguments

l

A variable, probably a list.

prune_empty_elts

A logical value. Should empty elements be pruned without counting them?

Value

A non-negative integer of the deepest depth of the list.

See Also

This is loosely based upon list.depth (internal to older versions of the Zelig package), but gives different answers.

Examples

1
2
3
4
5
6
7
8
9
list_depth(list(1))
list_depth(list(1, list(2:3, 4:6)))

# Atomic variables have depth 0
list_depth(1)

# Empty elements can be pruned before counting
list_depth(list())
list_depth(list(), prune_empty_elts = TRUE)

listless documentation built on May 2, 2019, 1:08 p.m.