Skip to content

Instantly share code, notes, and snippets.

@anandnalya
Created May 1, 2012 09:44
Show Gist options
  • Save anandnalya/2566854 to your computer and use it in GitHub Desktop.
Save anandnalya/2566854 to your computer and use it in GitHub Desktop.
x <- read.table("synthetic_control.data")
cat( "read", length(x[,1]), "records.\n")
# load clustering library
library(flexclust)
# get number of clusters from user
n <- as.integer( readline("Enter number of clusters: "))
# run kmeans clustering on the dataset
cl1 <- cclust(x, n)
print("clustering complete")
# show summary of clustering
summary(cl1)
# plot the clusters
plot(cl1, main="Clusters")
readline("Press enter for cluster histogram")
m<-info(cl1, "size") # size of each cluster
hist(rep(1:n, m), breaks=0:n, xlab="Cluster No.", main="Cluster Plot")
readline("Press enter for a plot of distance of data points from its cluster centorid")
stripes(cl1)
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment