Learn R Programming

soundcorrs (version 0.4.0)

list.depth: Measure the depth of a nested list.

Description

Check how many levels of nesting there are in a list.

Usage

list.depth(x, d = 0)

Arguments

x

[list] The list whose depth is to be gauged.

d

[integer] A technical variable, not supposed to be defined by the user. Defaults to 0.

Value

[integer] The depth of x.

Details

Checks how many times a list is nested. The function is recursive, but to save on execution time it doesn't have an elegant wrapper around it and has the argument d which collects the result, and which the user is supposed not to tinker with.

Examples

Run this code
# NOT RUN {
soundcorrs:::list.depth (list (1))
soundcorrs:::list.depth (list (list (1, list(2))))
# }

Run the code above in your browser using DataLab