R/Kmeans.R

Defines functions Kmeans

#####Using Keams for Providing Initial Values
Kmeans=function(rstat)
{
  wholeindex=stats::kmeans(rstat,2)$cluster
  mean1=mean(rstat[which(wholeindex==1)])
  mean2=mean(rstat[which(wholeindex==2)])
  if ((mean2)>(mean1)){
    wholeindex<-wholeindex-rep(1,length(rstat))
  }else{
    wholeindex[which(wholeindex==2)]<-0}
  return(wholeindex)
}

Try the BANFF package in your browser

Any scripts or data that you put into this service are public.

BANFF documentation built on May 29, 2017, 11:59 a.m.