Code for Clustering in R using Iris dataset

> View(iris) To know the optimal no of clusters, using hierarchical clustering methodology: > d=dist(scale(iris[,-5])) > h=hclust(d,method=’ward.D’) > plot(h,hang=-1) > k=kmeans(iris[,-5],3) > rect.hclust(h,h=35,border=”blue”) > k Following dendrogram appeared: Selecting 3 to be most optimal, applying k-means to get the centers for these 3 clusters: > k=kmeans(iris[,-5],3,nstart=20) By giving nstart=20, we are fixing the starting point[…]