search_node: Find element(s) in apsimx file

Description Usage Arguments Value Examples

View source: R/search.R

Description

Find element(s) in apsimx file

Usage

1
search_node(l, all = FALSE, max_depth = 1e+06, ...)

Arguments

l

The list of apsimx file

all

Whether to find all elements

max_depth

The maximum depth to search

...

Other names arguments for property to match

Value

A list matching all criteria if all equals to TRUE, A list with node and path if all equals to FALSE (default)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
wheat <- read_apsimx(system.file("Wheat.json", package = "rapsimng"))
# Return empty list if not found
search_node(wheat, Name = "Simulations1")
# Find root level
a <- search_node(wheat, Name = "Simulations")
a$path
# Find sub-level
a <- search_node(wheat, Name = "Wheat")
a$path
a <- search_node(wheat, `$type` = "Models.PMF.Cultivar, Models")
a$path

# Find multiple attributes
a <- search_node(wheat,
            Name = 'PotentialBranchingRate',
            `$type` = "Models.Functions.PhaseLookup, Models")
a$path
a$node$Name
# Find all cultivar nodes
 a <- search_node(wheat, `$type` = "Models.PMF.Cultivar, Models", all = TRUE)
length(a)

rapsimng documentation built on Sept. 9, 2021, 9:07 a.m.