[R] Printing zero as dot
Giovanni Petris
GPetris at uark.edu
Sat Apr 5 00:54:42 CEST 2003
Many thanks to J.R. Lockwood and to Sundar Dorai-Raj for sending me
their suggestions. I ended up using Sundar's function blended with a
flavour of `zapsmall':
print.matrix2 <- function(x, zero = ".", digits=getOption("digits"), ...) {
if (all(ina <- is.na(x)))
return(x)
if (length(digits) == 0)
stop("invalid digits")
mx <- max(abs(x[!ina]))
x <- round(x, digits = if (mx > 0)
max(0, digits - log10(mx))
else digits)
zeros <- which(x == 0, arr.ind = TRUE)
x[zeros] <- zero
print(x, quote = FALSE, right = TRUE, ...)
invisible()
}
Have a good weekend,
Giovanni
>
> 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
>
--
__________________________________________________
[ ]
[ Giovanni Petris GPetris at uark.edu ]
[ Department of Mathematical Sciences ]
[ University of Arkansas - Fayetteville, AR 72701 ]
[ Ph: (479) 575-6324, 575-8630 (fax) ]
[ http://definetti.uark.edu/~gpetris/ ]
[__________________________________________________]
More information about the R-help
mailing list