[R] Is there a bug in kmeans in package mva?

Art Salwin salwin at mitretek.org
Tue Jul 25 14:37:58 CEST 2000


I created a numeric vector of 49 elements and call kmeans as
follows:
kmeans(x,3)
The second argument, number of centers, is allowed to be a
constant per
the documentation.  However, the call doesn't work and
generates the
following error message:
Error in ncol(x) != ncol(centers) : comparison (2) is
possible only for vector types

Is this a bug or am I doing something wrong?

Looking at the code within kmeans, it appears the statement 
if(ncol(x)!=ncol(centers))
is where it fails, since centers does not get coerced to be
a matrix
and ncol(centers) is NULL.
-- 
Art Salwin
salwin at mitretek.org
(202) 863-2985
(202) 863-2988 (fax)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list