Re: [R] Error on distance matrix

From: Jari Oksanen <>
Date: Thu, 10 Jan 2008 14:06:42 +0000 (UTC)

Jari Oksanen <jari.oksanen <at>> writes:

> Marc Moragues <Marc.Moragues <at>> writes:
> >
> > Hi,
> >
> > I am trying to calculate a distance matrix on a binary data frame using
> > dist.binary() {ade4}. This is the code I run and the error I get:
> >
> > > sjlc.dist <- dist.binary(, method=2) #D = (a+d) /
> > (a+b+c+d)
> > Error in if (any(df < 0)) stop("non negative value expected in df") :
> > missing value where TRUE/FALSE needed
> >
> > I don't know if the problem are the missing values in my data. If so how
> > can I handle them?

> >
> Dear Marc Moragues,
> At least adding NA to a data.frame gave the same error message as you report
> above. Odds are good for NA being responsible (but we cannot know: we only
> guess).
> One solution is to use function designdist in vegan where you can with some
> acrobary design your own dissimilarity indices.

It is a bad habit to comment on yourself, but if you write stupid things, you should tell so: that designdist() "handles" missing values is accidental, unintentional and dangerous. Now you still should figure out *how* they are handled, and the function should warn users if they supply data with missing values. I hope that will be changed.

>Function designdist uses
> different notations, because its author hates that misleading and dangerous 2x2
> contingency table notation. The following, however, seems to define the same
> index as ade4:
> designdist(data, "sqrt(1-(2*J+P-A-B)/P)")
You can make this cuter:

designdist(data, "sqrt((A+B-2*J)/P)")

Cheers, Jari Oksanen mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 10 Jan 2008 - 14:09:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Jan 2008 - 15:30:05 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive