Skip to content
Prev 30212 / 398506 Next

Printing zero as dot

Giovanni Petris wrote:
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