![](/img/trans.png)
[英]Show point labels on hover when using fviz_dend from factoextra with ggplotly
[英]How do I change the labels of a dendogram using the fviz_dend function from the “factoextra” package in R?
我正在創建一個 shiny 應用程序,該應用程序以谷物數據集為例展示了不同的聚類技術,例如分層和 k 均值聚類。 我正在使用“factoextra”package 中的 fviz_dend function 創建我的樹狀圖。 但是,當我這樣做時,樹狀圖不會將谷物的名稱顯示為標簽,而是顯示數字表示。 有沒有辦法將數值更改為標簽? I am attaching below a picture of my current dendogram using the fviz_dend function and a picture of a dendogram I made using the plot function in base R. 請注意,由 plot function 創建的樹狀圖具有我需要的谷物標簽(我正在努力實現)。
使用 fviz_dend 創建的樹狀圖:
### Code for dendogram using fvizdend
hc <- hclust(dist(scale(xv), method = input$dmeth), method = input$meth)
fviz_dend(hc, k = input$clustgroup, cex = 0.5, k_colors = c("#2E9FDF", "#00AFBB", "#E7B800", "#FC4E07"),
color_labels_by_k = T, rect = T, show_labels = T)
使用 plot function 創建的樹狀圖:
hc <- hclust(dist(scale(xv), method = input$dmeth), method = input$meth)
plot(hc, labels = xv$Brand)
你試過用標簽設置xv
的row.names
嗎?
rownames(xv) <- xv$Brand
更改 hclust 對象的標簽(在您的情況下為 hc),然后更改 plot 樹狀圖。
hc$labels <- xv$Brand
library("factoextra")
fviz_dend(hc, cex = 0.5)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.