Skip to content

cluster - clusplot.default (PR#1249)

2 messages · Kjetil Halvorsen, Brian Ripley

#
The following code in clusplot.default (package cluster) is in error:

x1 <- cmdscale(x, k = 2, eig = TRUE)
        var.dec <- sum(x1$eig)/sum(diag(x1$x))
        if (var.dec < 0) 
            var.dec <- 0
        if (var.dec > 1) 
            var.dec <- 1
        x1 <- x1$points

x1 has components with names "points" and "eig", not "x", so 
sum(diag(x1$x)) returns 0, the division gives Inf which is later replaced 
by 1. 
So in the plot it is reported (always) that "These two components explain 
100% 
of the variability". 

Besides, is it reasonable that sum(NULL) returns 0 without at least a 
warning?

Another small point about the cluster package: it loads automatically
mva, but that is not mentioned in the Depends field in the description file.

Kjetil Halvorsen



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 7 Jan 2002 kjetilh@umsanet.edu.bo wrote:

            
Yes: an empty sum is zero in mathematics.  S code relies on such things.
It depends on base too, but that's not mentioned.  The convention is to
only include packages that are not in the standard tar bundle.
We can (and do) move things around between those, and indeed have talked
about some major reorganization of them (back as far DSC99, in fact).

You'll find most packages follow that convention: MASS uses almost all the
standard packages somewhere.