talgalili/dendextend

Bug in get_subdendrograms

chasemc opened this issue · 0 comments

Describe the bug
get_subdendrograms() only works if dendrogram has numeric labels. The example in the documentation works but only by chance.

To Reproduce

Code adapted from the example in the documentation

This seems to work:

library(dendextend)

iris[1:10, -5] %>%
  dist() %>%
  hclust() %>%
  as.dendrogram() %>%
  set("labels_to_character") %>%
  color_branches(k = 5) %>% 
  #dendextend::set_labels(paste0("a",labels(.) ))%>% 
  get_subdendrograms(5)

But un-commenting the line that adds an 'a' to each of the labels reveals it doesn't work

library(dendextend)

iris[1:10, -5] %>%
  dist() %>%
  hclust() %>%
  as.dendrogram() %>%
  set("labels_to_character") %>%
  color_branches(k = 5) %>% 
  dendextend::set_labels(paste0("a",labels(.) ))%>% 
  get_subdendrograms(5)

I've figured out the fix and will send a PR.