Reputation: 21
mydata<- read.csv("q.csv")
# K-Means Cluster Analysis
fit <- kmeans(mydata, 3) # 3 cluster solution
# get cluster means
abc<-aggregate(mydata,by=list(fit$cluster),FUN=mean)
abc[1]
# append cluster assignment
mydata <- data.frame(mydata, fit$cluster)
mydata
how do i access individual values of the k means result? Im able to access only the single vector using abc[1]
Upvotes: 1
Views: 58
Reputation: 53
In case nrow(mydata) == length(fit$cluster)
, I would try to use cbind function.
Otherwise you won't be able to do it.
Upvotes: 1