xpluck {crossmap} | R Documentation |
Get one or more elements deep within a nested data structure
Description
xpluck()
provides an alternative to purrr::pluck()
.
Unlike purrr::pluck()
, xpluck()
allows you to extract multiple indices at
each nesting level.
Usage
xpluck(.x, ..., .default = NULL)
Arguments
.x |
|
... |
A list of accessors for indexing into the object. Can be positive integers, negative integers (to index from the right), strings (to index into names) or missing (to keep all elements at a given level). Unlike |
.default |
Value to use if target is |
Value
Examples
obj1 <- list("a", list(1, elt = "foo"))
obj2 <- list("b", list(2, elt = "bar"))
x <- list(obj1, obj2)
xpluck(x, 1:2, 2)
xpluck(x, , 2)
xpluck(x, , 2, 1)
xpluck(x, , 2, 2)
xpluck(x, , 2, 1:2)
[Package crossmap version 0.4.0 Index]