Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • K-means clustering in R

    Sorry for posting my question here, I know that it is a Statat forum, but I don't know where to ask my question about R.

    I have an introductory course in Big Data and Machine Learning, and we learn about k-means clustering, and how to choose the number of cluster.

    Th teacher suggested the following code to do it:

    n=15
    Florida=numeric(n)
    for (i in 1:n)
    {FloridaClust[i] = kmeans(Florida[,PredVars],i)$tot.withinss}
    plot(1:15, FloridaClust,col="darkred", lwd=3, xlab="Number of Clusters", type="b", ylab="Total Within Cluster SS", col.axis="navyblue")

    Somehow, I cannot run it on my dataset, to be honest, I do not completely understand what the each part of the code does.
    My biggest problem is, that I don't know what this part is: [,PredVars]
    Does anyone have an idea?

    Thank you

  • #2
    R-help or Stack Overflow using an R tag are some places to look. (A Stata question would predictably be treated as off-topic in either place, and so too is this question here.)

    Comment

    Working...
    X