library(plyr)
getwd()
## [1] "C:/Users/RISHI RAHUL/Desktop/Dataset/3 Data Sets/7 KmeansClustering"
#setwd("C:\\Users\\RISHI RAHUL\\Desktop\\Dataset\\3 Data Sets\\")
#mydata <- read_excel("C:\\Users\\RISHI RAHUL\\Desktop\\Dataset\\3 Data Sets\\7 KmeansClustering\\University.xlsx")

x <- runif(50)
y <- runif(50)

data <- cbind(x, y)
plot(data)

plot(data, type = "n")

text(data, plot(data, type = "n",rownames(data)))

km <- kmeans(data, 4)
str(km)
## List of 9
##  $ cluster     : int [1:50] 2 4 2 3 2 1 2 4 1 4 ...
##  $ centers     : num [1:4, 1:2] 0.274 0.703 0.752 0.204 0.206 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:4] "1" "2" "3" "4"
##   .. ..$ : chr [1:2] "x" "y"
##  $ totss       : num 7.95
##  $ withinss    : num [1:4] 0.383 0.476 0.194 0.77
##  $ tot.withinss: num 1.82
##  $ betweenss   : num 6.12
##  $ size        : int [1:4] 11 13 7 19
##  $ iter        : int 2
##  $ ifault      : int 0
##  - attr(*, "class")= chr "kmeans"
#install.packages("animation")
library(animation)

#km1 <- kmeans.ani(data, 4)
#km$centers