From a dataframe data.main
, I am able to generate a hclust
dendrogram as,
aa1<- c(2,4,6,8)
bb1<- c(1,3,7,11)
aa2<-c(3,6,9,12)
bb2<-c(3,5,7,9)
data.main<- data.frame(aa1,bb1,aa2,bb2)
d1<-dist(t(data.main))
hcl1<- hclust(d1)
plot(hcl1)
Further, I know there are ways to use a tree cutoff to color the branches or leaves. However, is it possible to color them based on partial column names or column number (e.g. I want that branch corresponding to aa1
, aa2
be red and bb1
and bb2
be blue)?
I have checked the R package dendextend
but am still not able to find a direct/easy way to get the desired result.