R-kmeans

data <- read.csv("//Users//tangjingxiao//Desktop//2.csv",header=T,sep="\t",encoding="utf-8")
data
fix(data)
View(data)
newdata <- t(data)
view(newdata)
View(newdata)
kc <- kmeans(newdata,30)
kc
plot(newdata,col=kc$cluster)
points(kc$centers, col = 1:2, pch = 8, cex = 2)
ss <- function(y) sum(scale(y, scale = FALSE)^2)
ss
## cluster centers "fitted" to each obs.:
fitted.newdata <- fitted(kc);
head(fitted.newdata);
resid.newdata<- newdata - fitted(kc);
resid

 

posted @ 2014-06-28 14:14  ilxx1988  阅读(142)  评论(1编辑  收藏  举报