I'm not sure if there are options for trading 0. One of the possibilities is to have your own functions print.numeric and print.integer.
print.integer <- print.numeric <- function(..., digs=1) { print(format(as.numeric(...), nsmall=digs), quote=F) }
It still requires print , but ahead of
> print(-1:5) [1] -1.0 0.0 1.0 2.0 3.0 4.0 5.0
Alternatively, you can directly use the
nsmall argument in the format.
mat <- matrix(as.numeric(rep(0:3, 5)), ncol=4) print(format(mat, nsmall=2), quote=F)
Ricardo saporta
source share