
Last chance! 50% off unlimited learning
Sale ends in
show
and print
methods for sparse
matrices.printSpMatrix(x, digits = getOption("digits"), maxp = getOption("max.print"),
zero.print = ".",
col.names, note.dropping.colnames = TRUE,
col.trailer = "", align = c("fancy", "right"))
sparseMatrix
.print.default
.options(max.print)
,
influences how many entries of large matrices are printed at all."."
may occasionally
be replaced by " "
(blank); using "0"
would look
almost like print()
ing of non-sparse matrix
should be printed, possibly abbreviated. The default is
taken from options("sparse.colnames")
if that is set, otherwise
col.names
is FALSE
if the dropping of the column names should be noted, TRUE
by default.show()
only, when suppressing columns.zero.print
codes
should be aligned, i.e., padded as strings. The default,
"fancy"
, takes some effort to align the typical
zero.print = "."
with the decimal points of the numbex
invisibly, see invisible
.sparseMatrix
and the
classes extending it; maybe spMatrix
as a simple
constructor of such matrices.f1 <- gl(5, 3, labels = LETTERS[1:5])
X <- as(f1, "sparseMatrix")
X ## <==> show(X) <==> print(X)
t(X) ## shows column names, since only 5 columns
X2 <- as(gl(12, 3, labels = paste(LETTERS[1:12],"c",sep=".")),
"sparseMatrix")
X2
## less nice, but possible:
print(X2, col.names = TRUE) # use [,1] [,2] .. => does not fit
t(X2) # suppressing column names
print(t(X2), col.names=TRUE)
print(t(X2), zero.print = "", col.names="abbr. 1")
print(t(X2), zero.print = "-", col.names="substring 2")
op <- options(max.print = 25000, width = 80)
sink(print(tempfile()))
M <- Matrix(0, 10000, 100)
M[1,1] <- M[2,3] <- 3.14
stopifnot((st <- system.time(show(M)))[1] < 1.0) # only 0.09 on cmath-3
sink()
st
options(op)
Run the code above in your browser using DataLab