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.
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
print(tree, "level", limit = NULL)
#> levelName level
#> 1 G 1
#> 2 ¦--C1 2
#> 3 ¦ ¦--C1.1 3
#> 4 ¦ ¦ ¦--A1 4
#> 5 ¦ ¦ ¦--A2 4
#> 6 ¦ ¦ ¦--A3 4
#> 7 ¦ ¦ °--A4 4
#> 8 ¦ °--C1.2 3
#> 9 ¦ ¦--A1 4
#> 10 ¦ ¦--A2 4
#> 11 ¦ ¦--A3 4
#> 12 ¦ °--A4 4
#> 13 ¦--C2 2
#> 14 ¦ ¦--C2.1 3
#> 15 ¦ ¦ ¦--C2.1.1 4
#> 16 ¦ ¦ ¦ ¦--A1 5
#> 17 ¦ ¦ ¦ ¦--A2 5
#> 18 ¦ ¦ ¦ ¦--A3 5
#> 19 ¦ ¦ ¦ °--A4 5
#> 20 ¦ ¦ °--C2.1.2 4
#> 21 ¦ ¦ ¦--A1 5
#> 22 ¦ ¦ ¦--A2 5
#> 23 ¦ ¦ ¦--A3 5
#> 24 ¦ ¦ °--A4 5
#> 25 ¦ ¦--C2.2 3
#> 26 ¦ ¦ ¦--A1 4
#> 27 ¦ ¦ ¦--A2 4
#> 28 ¦ ¦ ¦--A3 4
#> 29 ¦ ¦ °--A4 4
#> 30 ¦ °--C2.3 3
#> 31 ¦ ¦--C2.3.1 4
#> 32 ¦ ¦ ¦--A1 5
#> 33 ¦ ¦ ¦--A2 5
#> 34 ¦ ¦ ¦--A3 5
#> 35 ¦ ¦ °--A4 5
#> 36 ¦ °--C2.3.2 4
#> 37 ¦ ¦--A1 5
#> 38 ¦ ¦--A2 5
#> 39 ¦ ¦--A3 5
#> 40 ¦ °--A4 5
#> 41 °--C3 2
#> 42 ¦--C3.1 3
#> 43 ¦ ¦--A1 4
#> 44 ¦ ¦--A2 4
#> 45 ¦ ¦--A3 4
#> 46 ¦ °--A4 4
#> 47 °--C3.2 3
#> 48 ¦--A1 4
#> 49 ¦--A2 4
#> 50 ¦--A3 4
#> 51 °--A4 4
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
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.