This is helpful to get the attributes of branches of the leaves. For example, after we use color_branches, to get the colors of the labels to match (since getting the colors of branches to match those of the labels can be tricky).

get_leaves_edgePar(dend, simplify = FALSE, ...)

Arguments

dend

a dendrogram object

simplify

logical (default is FALSE). If TRUE, then the return vector is after using unlist on it.

...

not used

Value

A list (or a vector) with the dendrogram's leaves edgePar attribute

Examples

# define dendrogram object to play with:
hc <- hclust(dist(USArrests[1:5, ]), "ave")
dend <- as.dendrogram(hc)

# get_leaves_edgePar(dend) # error :)
get_leaves_edgePar(dend)
#> [[1]]
#> [1] NA
#> 
#> [[2]]
#> [1] NA
#> 
#> [[3]]
#> [1] NA
#> 
#> [[4]]
#> [1] NA
#> 
#> [[5]]
#> [1] NA
#> 
dend <- color_branches(dend, k = 3)
get_leaves_edgePar(dend)
#> [[1]]
#> [[1]]$col
#> [1] "#CC476B"
#> 
#> 
#> [[2]]
#> [[2]]$col
#> [1] "#228B00"
#> 
#> 
#> [[3]]
#> [[3]]$col
#> [1] "#228B00"
#> 
#> 
#> [[4]]
#> [[4]]$col
#> [1] "#0082CE"
#> 
#> 
#> [[5]]
#> [[5]]$col
#> [1] "#0082CE"
#> 
#> 
get_leaves_edgePar(dend, TRUE)
#>       col       col       col       col       col 
#> "#CC476B" "#228B00" "#228B00" "#0082CE" "#0082CE" 

dend <- dend %>% set("branches_lwd", c(2, 1, 2))
get_leaves_edgePar(dend)
#> [[1]]
#> [[1]]$col
#> [1] "#CC476B"
#> 
#> [[1]]$lwd
#> [1] 1
#> 
#> 
#> [[2]]
#> [[2]]$col
#> [1] "#228B00"
#> 
#> [[2]]$lwd
#> [1] 1
#> 
#> 
#> [[3]]
#> [[3]]$col
#> [1] "#228B00"
#> 
#> [[3]]$lwd
#> [1] 2
#> 
#> 
#> [[4]]
#> [[4]]$col
#> [1] "#0082CE"
#> 
#> [[4]]$lwd
#> [1] 1
#> 
#> 
#> [[5]]
#> [[5]]$col
#> [1] "#0082CE"
#> 
#> [[5]]$lwd
#> [1] 2
#> 
#> 

plot(dend)