Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't see the result of silhouette plot except for the axis(in R)

Tags:

r

silhouette

everyone. I have a problem in plotting silhouette chart in R.

It is my code.

#k-means clustering
#install.packages("cluster")
library(cluster)
kc <- kmeans(nsoap, centers=3)

dissE <- daisy(nsoap)
sk <- silhouette(kc$cl,dissE)

plot(sk)
dev.off()

I just got this result. It is without the contents...

enter image description here

How can I overcome this problem?

Thank you:)

like image 646
user5431097 Avatar asked Oct 10 '15 14:10

user5431097


1 Answers

Posting answer as this was the top result for a google search on this problem.

This is an issue with how the plot is rendered in RStudio.

This post (https://stackoverflow.com/a/34404740/7687105) shows how to set border = NA in the call to plot() to cause the plot to render correctly.

Another option used here (https://stackoverflow.com/a/34110332/7687105) is to call windows() in RStudio to get a separate window for graphics that plots the Silhouette Coefficients correctly without using the border= option.

like image 75
Ryan Cole Avatar answered Sep 18 '22 01:09

Ryan Cole