From maechler at stat.math.ethz.ch  Thu Oct 30 15:40:39 2003
From: maechler at stat.math.ethz.ch (maechler@stat.math.ethz.ch)
Date: Thu Oct 30 15:39:42 2003
Subject: [Rd] dist() objects with NA's don't print them (PR#4866)
Message-ID: <200310301440.h9UEed0P028152@pubhealth.ku.dk>

The print.dist() method in the mva package currently prints the
triangular distance matrices with the ``trick'' of setting the
(diagonal and) upper triangular part to NA, and then uses
print(mat, na = "") to print that matrix.
This is very much undesired if there are true NAs.

Reproducible example code:

(x <- cbind(c(1,NA,2,3), c(NA,2,NA,1)))
(d <- dist(x)) ## does not show the NAs
as.matrix(d)   ## now you see them

-- Transcript :

> (x <- cbind(c(1,NA,2,3), c(NA,2,NA,1)))
     [,1] [,2]
[1,]    1   NA
[2,]   NA    2
[3,]    2   NA
[4,]    3    1

> (d <- dist(x)) ## does not show the NAs

         1        2        3
2                           
3 1.414214                  
4 2.828427 1.414214 1.414214

> as.matrix(d)   ## now you see them
         1        2        3        4
1 0.000000       NA 1.414214 2.828427
2       NA 0.000000       NA 1.414214
3 1.414214       NA 0.000000 1.414214
4 2.828427 1.414214 1.414214 0.000000
> 

---------

The fix is to rewrite print.dist() by not using the above trick 
-- which I have almost finished and will commit to  R-patched.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><


[Rd] dist() objects with NA's don't print them (PR#4866)
maechler@stat.math.ethz.ch