Skip to contents

Functions to extract the 'depth' of an object

Usage

depth(x, ...)

# S3 method for default
depth(x, ...)

# S3 method for list
depth(x, ...)

Arguments

x

An object

...

Possible additional arguments passed to methods (not in use)

Value

A single integer

Details

This function does not count an empty lists (list()) as a level or NULL objects.

Examples

a <- c(1, 2, 3)
depth(a) # Vectors are 1L
#> [1] 1

b <- list(a = 1, b = list(list(1)))
depth(b)
#> [1] 3