adding variables to cfviz_cluster

40 Views Asked by At

I have built a cluster plot with fviz_cluster. shown in attached image.

fviz_cluster(hcpc, palette = c("blue", "red", "black"),
             ellipse.type = "convex", # Concentration ellipse
             star.plot = TRUE, # Add segments from centroids to items
             repel = TRUE, # Avoid label overplotting (slow)
             ggtheme = theme_minimal())

enter image description here

pca <- PCA(data.frame(data, row.names = 1), ncp = Inf, graph = TRUE, scale.unit = TRUE)

I want to add variables in the cluster plot to show a relation of respective variable with the cluster on which basis these are constrcted by HCPC function.

hcpc <- HCPC(pca,method = "ward", metric= "euclidean",consol=FALSE, graph=TRUE,
             graph.scale = "sqrt_inertia",order = T)

dataset is a as follows

Genotype var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var12 var13 var14 var15
sp1 1.637918 16.495 0.77675 7.477917 -0.01383 -0.26151 -0.23293 0.292033 0.485567 0.5669 0.392739 99.52778 -1.17835 0.229556 -0.39866
sp2 -0.32645 16.63333 1.037769 7.933333 0.3822 -0.44884 -0.43737 0.2689 0.474 0.516167 0.379568 98.66667 -0.12126 -1.33545 -1.23918
sp3 -0.36778 12.60417 0.169904 5.3975 -0.55788 -0.07758 0.084623 0.146567 0.629067 0.332833 -0.74823 103.75 -0.45396 -1.09686 -0.71563
sp4 -1.04965 15.9 0.295659 7.053333 -0.2199 -0.26855 0.194102 0.2245 0.557733 0.472933 -0.23829 92.33333 -0.75625 -1.33545 -1.23918
sp5 0.674863 10.76 -0.34865 5.046667 -0.45314 -0.17183 0.499055 0.2295 0.481067 0.470433 -0.40215 71 -0.75752 -1.33545 -1.23918
sp6 -1.187 9.033333 -0.63144 3.826667 -0.64804 -0.99823 -0.73975 0.180933 0.260633 0.3383 -1.09673 108.6667 -0.82717 -1.33545 -1.23918
sp7 -0.03838 5.406667 -1.32602 1.091 -1.34433 1.367319 1.43931 0.158867 0.578267 0.350567 -0.55303 88.66667 0.391606 -0.11855 0.625054
sp8 -0.33247 11.2025 -0.13444 4.6475 -0.26406 0.023718 0.282222 0.168533 0.544867 0.3375 0.560527 43.55556 -1.18273 -0.65414 -0.28142
sp9 0.283242 12.36 -0.20031 5.233333 -0.42353 -0.03327 0.46696 0.216133 0.488833 0.4381 -0.38686 87.66667 -0.48168 0.560739 -0.60173
sp10 0.473607 11.06 -0.19594 5.197333 -0.31603 -0.08682 0.270725 0.190367 0.5792 0.433367 -1.07407 71.33333 -0.22937 -0.49644 -0.43777
sp11 1.506141 17.53333 0.421256 7.62 -0.20013 -0.2023 0.187563 0.253067 0.4451 0.5073 -0.72271 44 -1.43844 0.833085 -0.54608
sp12 0.826359 12.01333 -0.15668 5.438 -0.68214 0.186844 0.702316 0.234733 0.472267 0.462133 -0.13121 79.33333 0.26208 0.343665 -0.18439
sp13 -0.81205 8.366667 -0.82383 2.94 -0.70493 0.448508 0.793381 0.1573 0.683033 0.398533 -1.2223 79.66667 -0.51911 -0.70502 -0.34878
sp14 0.15826 12.32 -0.23267 4.966667 -0.47136 0.160231 0.513613 0.2562 0.467867 0.501533 -0.26897 157.3333 0.683273 -0.49121 0.340543
sp15 0.841028 17.06667 0.436611 7.23 -0.22218 -0.0743 0.171861 0.214567 0.538033 0.4394 -0.12116 128.3333 0.378802 0.015846 0.526323
sp16 -0.37529 6.403333 -1.12965 1.942333 -1.04587 0.774613 1.105434 0.118233 0.603967 0.36925 -0.67939 102.3333 -0.5009 0.622995 0.728144
sp17 0.425415 8.96 -0.86026 2.857333 -1.00362 0.714724 1.103843 0.2048 0.481733 0.4071 -0.11519 118 -0.06422 0.14123 0.264738
sp18 0.409411 11.30333 -0.52009 4.11 -0.63759 0.517846 0.702689 0.143367 0.598533 0.352433 -1.42041 55 -0.60815 -0.50147 0.351138
sp19 2.260841 10.61333 -0.50895 4.044 -1.17319 1.015295 1.126482 0.223133 0.559833 0.442733 0.464186 129.6667 0.268648 0.007618 0.538839
sp20 1.288929 7.223333 -0.90727 1.138667 -1.59676 1.704387 0.880127 0.098067 0.618433 0.2325 -1.81553 145.6667 -0.05645 0.851715 0.37077
sp21 -0.4669 7.194167 -1.03123 1.9675 -1.42041 0.958772 1.070749 0.108933 0.5125 0.227667 -0.50591 144.9167 0.56866 0.32833 1.275744
sp22 -0.51754 6.656667 -1.33466 1.080667 -1.58034 1.576634 1.683792 0.172667 0.632233 0.3988 -0.71183 145 0.705613 0.503667 0.876036
sp23 0.562136 9.703333 -0.73487 3.222333 -0.96489 0.817607 1.050613 0.165233 0.534833 0.335733 0.215271 223.6667 1.571329 -1.14217 -0.46953
sp24 0.133826 7.99 -1.15028 1.643333 -1.16784 1.243086 1.278266 0.176967 0.532233 0.3476 0.503408 87.33333 -0.38446 0.610718 0.120317
0

There are 0 best solutions below