Skip to contents

This function creates a visual representation of the hierarchical structure

Usage

draw_cluster_structure(n, labels = NULL, resp = NULL, output = "tree")

Arguments

n

same from cluster_gen

labels

corresponds to cluster_labels from cluster_gen

resp

corresponds to resp_labels from cluster_gen

output

"tree" draws a tree-like structure on the console, "text" prints the structure as a character vector

Value

Prints structure to console.

Note

This function is useful for checking how a list() object looks as a hierarchical structure, usually to be used as the n and/or N arguments of the cluster_gen function.

Examples

n <- c(2, 4, 3)
draw_cluster_structure(n)
#> school1
#> ├─school1_class1 (3 students)
#> ├─school1_class2 (3 students)
#> ├─school1_class3 (3 students)
#> └─school1_class4 (3 students)
#> school2
#> ├─school2_class1 (3 students)
#> ├─school2_class2 (3 students)
#> ├─school2_class3 (3 students)
#> └─school2_class4 (3 students)
draw_cluster_structure(n, output = "text")
#>  [1] "\033[37mschool1\033[39m"                     
#>  [2] "├─school1_class1 \033[2m(3 students)\033[22m"
#>  [3] "├─school1_class2 \033[2m(3 students)\033[22m"
#>  [4] "├─school1_class3 \033[2m(3 students)\033[22m"
#>  [5] "└─school1_class4 \033[2m(3 students)\033[22m"
#>  [6] "\033[37mschool2\033[39m"                     
#>  [7] "├─school2_class1 \033[2m(3 students)\033[22m"
#>  [8] "├─school2_class2 \033[2m(3 students)\033[22m"
#>  [9] "├─school2_class3 \033[2m(3 students)\033[22m"
#> [10] "└─school2_class4 \033[2m(3 students)\033[22m"