The current documentation for as.dist() contains >> Usage: >> >> as.dist(m, diag = FALSE, upper = FALSE) >> >> >> Arguments: >> >> m: A matrix of distances to be converted to a '"dist"' object >> (only the lower triangle is used, the rest is ignored).
and indeed, as.dist(m) currently takes almost anything for which as.matrix(m) works and returns its lower triangle without a warning even in several non-sense situations, such as - non-numeric - non-square - non-symmetric matrices (or data frames eg.). (where I can see arguments why it can be useful in this third case, to just ignore everything in the upper triangle) E.g., m <- cbind(1,7,1:4) cm <- paste(m,"p", sep="") ; dim(cm) <- dim(m) ; cm d <- as.dist(cm) ## --> no warning, but complete non-sense d # Printing now gives ## Error in df + t(df) : non-numeric argument to binary operator So, adding something like as.numeric(.) somewhere is definitely wanted. However, I wonder if we shouldn't also change the "(only the lower triangle is used, the rest is ignored)" part in the documentation and augment the code by at least give warnings in some cases {e.g. the non-square ones}. Opinions? Martin Maechler <[EMAIL PROTECTED]> 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 <>< ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel