Skip to content

Error in if (color == "cluster") color <- "default" : the condition has length > 1 #180

@14500066alga

Description

@14500066alga

fviz_dend(hc, cex = 0.5,
main = "Dendrogram - ward.D2",
xlab = "Objects", ylab = "Distance", sub = "")
fviz_dend(hc, cex = 0.5, horiz = TRUE)

I am doing some practice as follows:
It’s also possible to cut the tree at a given height for partitioning the data into multiple
groups as described in the previous chapter: Hierarchical clustering (Chapter 7). In
this case, it’s possible to color branches by groups and to add rectangle around each
group.
When I try to run the code (below):

fviz_dend(hc, k = 4, # Cut in four groups
cex = 0.5, # label size
k_colors = c("#2E9FDF", "#00AFBB", "#E7B800", "#FC4E07"),
color_labels_by_k = TRUE, # color labels by groups
rect = TRUE, # Add rectangle around groups
rect_border = c("#2E9FDF", "#00AFBB", "#E7B800", "#FC4E07"),
rect_fill = TRUE)

It resulted in this error (below):
Error in if (color == "cluster") color <- "default" :
the condition has length > 1

Please can some gives the solution for this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions