viewAHPtree: View an AHP tree

library(AHPtools)
library(readxl)

Introduction

This vignette shows how to use the viewAHPtree() function to build a hierarchical AHP structure from an Excel file. The example file is bundled with the package.

Step 1: Load the example AHP file

file <- system.file("extdata", "example_transport.xlsx", package = "AHPtools")

Step 2: Read the AHP structure

We assume the AHP structure is in the “ahp” sheet.

AHPstruc <- read_excel(file, sheet = "ahp")
print(AHPstruc, n=Inf)
#> # A tibble: 15 × 3
#>    Node   Parent Children_Ordered
#>    <chr>  <chr>  <chr>           
#>  1 G      <NA>   C1,C2,C3        
#>  2 C1     G      C1.1,C1.2       
#>  3 C2     G      C2.1,C2.2,C2.3  
#>  4 C3     G      C3.1,C3.2       
#>  5 C2.1   C2     C2.1.1,C2.1.2   
#>  6 C2.3   C2     C2.3.1,C2.3.2   
#>  7 C1.1   C1     A1,A2,A3,A4     
#>  8 C1.2   C1     A1,A2,A3,A4     
#>  9 C2.2   C2     A1,A2,A3,A4     
#> 10 C3.1   C3     A1,A2,A3,A4     
#> 11 C3.2   C3     A1,A2,A3,A4     
#> 12 C2.1.1 C2.1   A1,A2,A3,A4     
#> 13 C2.1.2 C2.1   A1,A2,A3,A4     
#> 14 C2.3.1 C2.3   A1,A2,A3,A4     
#> 15 C2.3.2 C2.3   A1,A2,A3,A4

Step 3: Create the AHP Tree

tree <- viewAHPtree(AHPstruc)

Another example

file <- system.file("extdata", "example_automobile.xlsx", package = "AHPtools")
AHPstruc2 <- read_excel(file, sheet = "AHP")
print(AHPstruc2, n=Inf)
#> # A tibble: 5 × 3
#>   Node  Parent Children_Ordered    
#>   <chr> <chr>  <chr>               
#> 1 G     <NA>   HRT,MDC,SCD,SSR     
#> 2 HRT   G      PTS,TUR,OCL         
#> 3 MDC   G      AM, RC, SC          
#> 4 SCD   G      SD,ES,RLA,IGI,GT    
#> 5 SSR   G      SSP, EA, CSR, SE, FR
tree <- viewAHPtree(AHPstruc2)
print(tree, "level", limit = NULL)
#>       levelName level
#> 1  G                1
#> 2   ¦--HRT          2
#> 3   ¦   ¦--PTS      3
#> 4   ¦   ¦--TUR      3
#> 5   ¦   °--OCL      3
#> 6   ¦--MDC          2
#> 7   ¦   ¦--AM       3
#> 8   ¦   ¦-- RC      3
#> 9   ¦   °-- SC      3
#> 10  ¦--SCD          2
#> 11  ¦   ¦--SD       3
#> 12  ¦   ¦--ES       3
#> 13  ¦   ¦--RLA      3
#> 14  ¦   ¦--IGI      3
#> 15  ¦   °--GT       3
#> 16  °--SSR          2
#> 17      ¦--SSP      3
#> 18      ¦-- EA      3
#> 19      ¦-- CSR     3
#> 20      ¦-- SE      3
#> 21      °-- FR      3

Summary

The viewAHPtree() function processes the input data to build the hierarchical structure of criteria and sub-criteria used in AHP. This vignette demonstrates loading the data and visualizing the tree structure.