findEntry {rgl2gltf}R Documentation

Find a component of a recursive object

Description

findEntry searches recursive objects for components matching a condition. namePattern creates a test of whether the component name matches a pattern. hasClass creates a test of whether the component has a class.

Usage

findEntry(x, test, ..., path = c())
namePattern(pattern)
hasClass(class)

Arguments

x

The recursive object to search.

test

A test function. See Details below.

pattern

A regexp pattern to match the desired name(s).

class

A class name to search for.

...

Optional additional arguments to pass to the test function.

path

For internal use: names to prepend to the path.

Details

Utility/debugging functions to search a large recursive object for a particular component name or class.

The test function should have header function(name, value), and may include other arguments which will be taken from ....

Value

findEntry returns a list with one entry per hit. Each entry in the list is a named vector giving the path to the hit, numerically in the values, and as an R expression by concatenating the names. The test functions will be passed single names and values, and should return a single logical result.

Examples

x <- list( a = list( b = list(c(d="A", e="B"), 1L, 1:3)))
locations <- findEntry(x, namePattern("e"))
locations

#This shows how the result can be used:
x[[locations[[1]]]]
expr <- paste0(c("x", names(locations[[1]])), collapse = "")
expr
eval(parse(text=expr))

findEntry(x, hasClass("integer"))

[Package rgl2gltf version 1.0.3 Index]