Calculates the depth of a list

depth(this, thisdepth = 1)

Arguments

this

A list whose depth needs to be calculated

thisdepth

The default value if the list is flat

Value

An integer specifying the depth of a list

See also

https://stackoverflow.com/a/13433689/1987629 (Function copied from)

Examples

depth(list(list(1, 2), list(2, 3))) # 3
#> [1] 3
depth(1:5) # 1
#> [1] 1
depth(list(list(1, 2), list(2, list(3, 4)))) # 4
#> [1] 4
depth(list(1:2, 3:4)) # 2
#> [1] 2