1
$\begingroup$

I just followed the tutorial trying to do clustering on my own data, but I can't visualize it because fviz_cluster function is giving me an error:

Error in if (xlab == "x") xlab <- "x value" : argument is of length zero

Here is the code I am running:

library("fpc")
db <- fpc::dbscan(rtsne$Y, eps = 0.15, MinPts = 5)
# Plot DBSCAN results
library("factoextra")
fviz_cluster(db, data = rtsne$Y, stand = FALSE,
        ellipse = FALSE, show.clust.cent = FALSE,
         geom = "point",palette = "jco", ggtheme = theme_classic())

How can I make fviz_cluster function working?

Update

Filed a bug: https://github.com/kassambara/factoextra/issues/62

$\endgroup$
1
$\begingroup$

I actually found an answer just accidentally. It is very unfortunate that factoextra documentation does not explicitly say that data parameter should be of data.frame type. In my case rtsne$Y was a matrix. The error that factoextra is giving is very uninformative.

Here is the code that ultimately worked:

fviz_cluster(db, 
----->  data = as.data.frame(rtsne$Y), 
        stand = FALSE,
        ellipse = FALSE, show.clust.cent = FALSE,
        geom = "point",palette = "jco", ggtheme = theme_classic())
| improve this answer | |
$\endgroup$
  • $\begingroup$ I am using fviz_cluster as well, but for PCA clustering. I have a separate question that I've asked but haven't gotten the perfect answer, when you put geom = "label", where does it take the labels from? My guess would be the rownames, but the rownames in my data.frame are non unique. What do I do? $\endgroup$ – rishi Mar 20 '18 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.