Utilities for formatting sparse numeric matrices in a flexible way.
These functions are used by the format and print
methods for sparse matrices and can be applied as well to standard Rmatrices. Note that all arguments but the first are optional.
formatSparseM() is the main workhorse of
formatSparseM, the format method.
.formatSparseSimple() is a simple helper function, also dealing
with (short/empty) column names construction.
character which should be used for
structural zeroes. The default "." may occasionally
be replaced by " " (blank); using "0" would look
almost like print()ing of non-sparse matrices
align
a string specifying how the zero.print codes
should be aligned, see formatSpMatrix.
dimnames to be used; a list (of length two)
with row and column names (or NULL).
Value
a character matrix like cx. As this is a dense matrix,
do not use this function for really large (really) sparse matrices!
See Also
formatSpMatrix which calls formatSparseM() and is
the format method for sparse matrices.
printSpMatrix which is used by the (typically
implicitly called) show and print methods
for sparse matrices.
m <- suppressWarnings(matrix(c(0, 3.2, 0,0, 11,0,0,0,0,-7,0), 4,9))
fm <- formatSparseM(m)
noquote(fm)
## nice, but this is nicer :print(fm, quote=FALSE, right=TRUE)
## and "the same" as :Matrix(m)