library(factoextra) # 可视化
library(FactoMineR) # PCA 聚类
library(tidyverse)
df <- iris %>%
select(-Species) %>%
na.omit() %>%
scale() %>%
scale(center = TRUE, scale = FALSE)
res.pca <- PCA(df, ncp = 3, graph = FALSE)
res.hcpc <- HCPC(res.pca, graph = FALSE)
fviz_dend(res.hcpc,
cex = 0.7, # Label size
palette = "lancet", # Color palette see ?ggpubr::ggpar
rect = TRUE, rect_fill = TRUE, # Add rectangle around groups
rect_border = "lancet", # Rectangle color
labels_track_height = 0.8 # Augment the room for labels
)
fviz_cluster(res.hcpc,
repel = TRUE, # Avoid label overlapping
show.clust.cent = TRUE, # Show cluster centers
palette = "jco", # Color palette see ?ggpubr::ggpar
ggtheme = theme_minimal(),
main = "Factor map"
)
plot(res.hcpc, choice = "3D.map")
标签:scale,FALSE,center,Hclust,library,PCA,Dendrogram,pca
From: https://blog.csdn.net/weixin_47634487/article/details/139928740