Load a decision tree from a JSON file (Hierarchical Format)
load_tree_json.Rd
Reads a JSON file from a given path and constructs a tree. This
function expects the JSON to define the tree in a hierarchical (nested)
format. It uses load_tree_node_list
to construct the tree object.
Value
A data.tree
object, fully constructed and initialised with answer
and confidence
attributes set to NA
.
See also
load_tree_node_list()
for the underlying constructor function.
Examples
#' # Load data from the `ethical.json` file included with this package
path <- system.file("extdata", "ethical.json", package = "andorR")
ethical_tree <- load_tree_json(path)
# View the tree
print_tree(ethical_tree)
#> Tree Rule Answer Confidence
#> Invest in Company X AND
#> |-- Financial Viability AND
#> | |-- Profitability and Growth Signals OR
#> | | |-- FIN1
#> | | |-- FIN2
#> | | `-- FIN3
#> | `-- Solvency and Stability AND
#> | |-- FIN4
#> | `-- FIN5
#> |-- Acceptable Environmental Stewardship OR
#> | |-- Has a Clean Current Record AND
#> | | |-- ENV1
#> | | |-- ENV2
#> | | `-- ENV3
#> | `-- Has a Credible Transition Pathway OR
#> | |-- ENV4
#> | |-- ENV5
#> | `-- ENV6
#> |-- Demonstrable Social Responsibility OR
#> | |-- Shows Excellent Internal Culture OR
#> | | |-- SOC1
#> | | |-- SOC2
#> | | |-- SOC3
#> | | `-- SOC4
#> | `-- Has a Positive External Impact AND
#> | |-- SOC5
#> | |-- SOC6
#> | `-- SOC7
#> `-- Strong Corporate Governance AND
#> |-- GOV1
#> |-- GOV2
#> |-- GOV3
#> |-- GOV4
#> `-- GOV5