The depth of a vector is basically how many levels that you can index into it.

vec_depth(x)

Arguments

x

A vector

Value

An integer.

Examples

x <- list( list(), list(list()), list(list(list(1))) ) vec_depth(x)
#> [1] 5
x %>% map_int(vec_depth)
#> [1] 1 2 4