name the elements of a list of lists by the value of the element
elementName
of each sublist
Usage
nameByElement(x, elementName = "name")
Arguments
- x
list of lists
- elementName
name of element to be looked up in each sublist of
x
Examples
L <- list(
list(group = "A", value = 1),
list(group = "B", value = 2)
)
nameByElement(L, "group")
#> $A
#> $A$group
#> [1] "A"
#>
#> $A$value
#> [1] 1
#>
#>
#> $B
#> $B$group
#> [1] "B"
#>
#> $B$value
#> [1] 2
#>
#>