STHDA forum

factoextra » [Solved] fviz_cluster(): Visualizing Clusters with PC3 and PC4

Administrator

rank_admin.png

Avatar

Signed up since: 10/02/2013

Messages: 32

On 08/09/2017 at 14h26
(e-mail from a factoextra user)

I am using your great package 'fviz_cluster' to visualize my cluster partition object obtained from 'CLARA' over PC1 (dim1) and PC2(dim2). But I want to visualize it with PC3 and PC4 as well. I tried using the argument 'choose.vars= c(PCA$scores[,"Comp.3"],PCA$scores[,"Comp.4"])' where PCA is my princomp object and PCA$scores[,"Comp.3"] is the PC3 scores for each of my observations in my dataset. However, I get an error message.

"Error in data[, choose.vars, drop = FALSE] :
only 0's may be mixed with negative subscripts"


I can't understand this error. Could you please help me visualize my cluster solution with PC3(dim3) and PC4(dim4)?
Website    

Administrator

rank_admin.png

Avatar

Signed up since: 10/02/2013

Messages: 32

On 08/09/2017 at 14h31
To visualize the clusters with PC3 and PC4, specify the argument axes = c(3, 4) as follow:

Code R :
 
library(cluster)
library(factoextra)
res.clust <- clara(iris[, -5], k = 3 )
fviz_cluster(res.clust, axes = c(3, 4))
 


The output looks like this:

Website    
Answer
You aren't allowed to write in this category
1 User online : 0 Administrator, 0 Moderator, 0 Member and 1 Visitor
User online : No member online