Skip to contents

Extract elements of lists using x-path-like syntax.

Usage

list_xpath(l, ...)

Arguments

l

A hierarchical list.

...

Character strings describing the path down the hierarchy.

Examples

l = list(
  a = list(
    A = list(
      i = 1,
      ii = 2
    ),
    B = list(
      i = 3,
      ii = 4
    )
 ),
 b = list(
    A = list(
      i = 5,
      ii = 6
    ),
    B = list(
      i = 7,
      ii = 8
    )
  )
)
list_xpath(l, "A", "i")
#> $a
#> [1] 1
#> 
#> $b
#> [1] 5
#> 
list_xpath(l, "B", "ii")
#> $a
#> [1] 4
#> 
#> $b
#> [1] 8
#>