I am trying to determine optimal number of clusters.
# Determine optimal number of clusters
wss<-rep(0,2)
wss[1]<-sum(scale(price[,2:2],scale=FALSE)^2)
for(i in 2:16)
wss[i]<-sum(kmeans(price[,2:2],centers=i)$withinss)
plot(4:2,wss,type="b",xlab="Number of clusters",ylab="Within-cluster sum of squares")
Every line works except the last one. The last one gives an error:
Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ
I have tried some solutions from other questions but no luck. Any advice? Thanks a tons!!
SAMPLE DATA:
Country Price
Albania 1.57
Andorra 1.24
Azerbaijan 0.47
Austria 1.33
Belarus 0.73
Belgium 1.54
Bosnia & Herz. 1.29
Bulgaria 1.13
Croatia 1.44
Czech Rep. 1.32
Cyprus 1.28
Denmark 1.74
Estonia 1.41
Finland 1.61
France 1.67
Georgia 0.9
dputand the expected output - Sonnydput(yourData)ordput(head(yourData))to share data - Iman