xpluck | R Documentation |
xpluck()
provides an alternative to purrr::pluck()
.
Unlike purrr::pluck()
, xpluck()
allows you to extract multiple indices at
each nesting level.
xpluck(.x, ..., .default = NULL)
.x |
A list or vector |
... |
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 |
A list or vector.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.