pluck_depth: Compute the depth of a vector

View source: R/pluck-depth.R

pluck_depthR Documentation

Compute the depth of a vector

Description

The depth of a vector is how many levels that you can index/pluck into it. pluck_depth() was previously called vec_depth().

Usage

pluck_depth(x, is_node = NULL)

Arguments

x

A vector

is_node

Optionally override the default criteria for determine an element can be recursed within. The default matches the behaviour of pluck() which can recurse into lists and expressions.

Value

An integer.

Examples

x <- list(
  list(),
  list(list()),
  list(list(list(1)))
)
pluck_depth(x)
x |> map_int(pluck_depth)

purrr documentation built on Aug. 10, 2023, 9:08 a.m.