I want to plot a dendrogram of a data frame coloring the members based on the values in column X like something similar to as shown in the dendrogram below. Is it possible?
I checked other posts in this forum but could not figure out a way to plot the dendrogram with colored branches based on the column values without K means value.
# Data frame df
X
a 1
b 2
c 1
d 2
e 3
f 1
g 3
df <- dist(df)
d <- dist(df, method = "euclidean")
fit <- hclust(d, method="ward")
plot(fit)