[R] Beginners Question

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Jun 2 08:21:52 CEST 2007


That two distances are the same is *not* what the message says.

You can't just look at elements of the results of dist() and simply relate 
them back to object numbers.  Try as.matrix(x.dist) for a human-readable 
form.


On Fri, 1 Jun 2007, Thomas Zastrow wrote:

> Dear all,
>
> I'm completely new to R and at first I must say that it is a great program!
>
> But I have a problem with the function isoMDS from the MASS package. I
> have this code which I load with source() from a file:
>
> x <- c(163.59514923926784, 150.01448475257115, ...... {here are some
> more values})
> x.sort <- sort(x)
> x.dist <- dist(x.sort)
> library(MASS)
> x.mds <- isoMDS(x.dist)
> plot(x.mds$points, type="n")
> text(x.mds$points, labels=as.character("x"))
>
> The problem is in the line where the isoMDS function is applied: I got
> the error:
>
> Fehler in isoMDS(x.dist) : zero or negative distance between objects 9
> and 10
>
> When I look at values 8 and 9 of x.dist, I see that they have the same
> values (I'm not wrong, it's values of 8 and 9 and not 9 and 10):
>
> x.dist[8:9]
> [1] 39.8214  39.8214
>
> So, just to give'm a try, I changed the value of x.dist[8]:
>
> x.dist[8] <- c(39.7)
>
> Now, there are defintitely different values in this part of x.dist:
>
> x.dist[7:10]
> [1] 39.69898     39.70000      39.82140      39.98892
>
> But when I start isoMDS again, I got again the error:
>
> x.mds <- isoMDS(x.dist)
> Fehler in isoMDS(x.dist) : zero or negative distance between objects 9
> and 10
>
>
> So, where's my error?
>
> Thank you!
>
> Best,
>
> Tom
>
>
>

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list