Skip to contents

A convenience function to organize information, mostly in YAML sequences.

Usage

nameLists(list, name)

Arguments

list

The list of lists

name

The name of the element holding the names

Value

The list of lists, with each list named with name

Examples

### Create a test object
testObject <-
  list(
    list(elementId = "first",
         someOther = "stuff"),
    list(elementId = "second",
         someOther = "stuff")
  );

### Show it
testObject;
#> [[1]]
#> [[1]]$elementId
#> [1] "first"
#> 
#> [[1]]$someOther
#> [1] "stuff"
#> 
#> 
#> [[2]]
#> [[2]]$elementId
#> [1] "second"
#> 
#> [[2]]$someOther
#> [1] "stuff"
#> 
#> 

### Show the result of applying nameLists
clairvoyant::nameLists(
  testObject,
  "elementId"
);
#> $first
#> $first$elementId
#> [1] "first"
#> 
#> $first$someOther
#> [1] "stuff"
#> 
#> 
#> $second
#> $second$elementId
#> [1] "second"
#> 
#> $second$someOther
#> [1] "stuff"
#> 
#>