[R] Is there a bug in kmeans in package mva?
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Tue Jul 25 14:55:10 CEST 2000
On Tue, 25 Jul 2000, Art Salwin wrote:
> I created a numeric vector of 49 elements and call kmeans as
> follows:
The help page says
x: A data frame or matrix of data.
so that is your error.
> 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
right, ncol(x) is NULL.
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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