~ubuntu-branches/ubuntu/wily/r-cran-kernlab/wily

« back to all changes in this revision

Viewing changes to R/specc.R

  • Committer: Package Import Robot
  • Author(s): Dirk Eddelbuettel
  • Date: 2015-08-05 15:11:28 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150805151128-h5c834lqz4x1dyny
Tags: 0.9-22-1
* New upstream release

* debian/control: Set Build-Depends: to current R version 

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
    res <- kmeans(yi, centers, iterations)
189
189
  }
190
190
  
191
 
  cent <- matrix(unlist(lapply(1:nc,ll<- function(l){colMeans(x[which(res$cluster==l),])})),ncol=dim(x)[2], byrow=TRUE)
 
191
  cent <- matrix(unlist(lapply(1:nc,ll<- function(l){colMeans(x[which(res$cluster==l), ,drop=FALSE])})),ncol=dim(x)[2], byrow=TRUE)
192
192
  
193
 
  withss <- unlist(lapply(1:nc,ll<- function(l){sum((x[which(res$cluster==l),] - cent[l,])^2)}))
 
193
  withss <- unlist(lapply(1:nc,ll<- function(l){sum((x[which(res$cluster==l),, drop=FALSE] - cent[l,])^2)}))
194
194
  names(res$cluster) <- rown
195
195
  return(new("specc", .Data=res$cluster, size = res$size, centers=cent, withinss=withss, kernelf= kernel))
196
196