create_tree: Tree Construction from DEXi's XML Output

View source: R/create_tree.R

create_treeR Documentation

Tree Construction from DEXi's XML Output

Description

Constructs a Tree objects using the XML representation from a DEXi model.

Usage

create_tree(main_tree, which_root = "all", correct = FALSE)

Arguments

main_tree

A character or an object of class XML. Either the path to the .dxi file containing the tree (character) or the XML object that represents the primary tree structure and should encompass the DEXi decision model.

which_root

an integer to indicate which tree to create among several in a .dxi or "all" (default) to create them all.

correct

A logical. If TRUE, use some correction function to avoid special character as " ' ".

Details

Iterates over every root attribute in the provided XML to create tree structures that depict the hierarchical decision model.

Value

A list of Tree objects, each corresponding to a unique root attribute in the DEXi XML layout. Each tree details the root attribute, nodes, leaves, depth, and other associated data regarding the decision model's configuration.

Examples

# With a Path
dxi_masc2_path <- system.file("extdata", "arborescence_MASC_2_0.dxi", package = "dexisensitivity")
tree <- create_tree(dxi_masc2_path)
tree

# With an XML
dxi_masc2_path <- system.file("extdata", "arborescence_MASC_2_0.dxi", package = "dexisensitivity")
masc2_xml <- XML::xmlDeserializeHook(dxi_masc2_path)
tree <- create_tree(masc2_xml)
tree


dexisensitivity documentation built on Oct. 30, 2024, 1:08 a.m.