Giovanni Petris wrote:
I'm pretty sure I've seen some examples of a function printing zero
entries in a matrix as dots, but I'm not able to find it now...
Any suggestions...? Thanks in advance. (Of course, I might have dreamt
of such a function...)


Best,
Giovanni


I just so have something that may help:


print.matrix2 <- function(x, zero = ".", ...) {
  zeros <- which(x == 0, arr.ind = TRUE)
  x[zeros] <- zero
  print(x, quote = FALSE, right = TRUE, ...)
  invisible()
}

> print.matrix2(diag(5))
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    .    .    .    .
[2,]    .    1    .    .    .
[3,]    .    .    1    .    .
[4,]    .    .    .    1    .
[5,]    .    .    .    .    1
>

Sundar

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to