Skip to contents

Reads a CSV file from a given path and constructs a tree. This function expects the CSV to define the tree in a relational format with id and parent columns defining the hierarchy and name, question (for leaves) and rule (for nodes) columns for the decision tree attributes.

Usage

load_tree_csv(file_path)

Arguments

file_path

The path to the .csv file.

Value

A data.tree object, fully constructed and initialised with answer and confidence attributes set to NA.

See also

load_tree_df() for the underlying constructor function.

Examples

# Load data from the `ethical.csv` file included with this package
path <- system.file("extdata", "ethical.csv", package = "andorR")
ethical_tree <- load_tree_csv(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