Rev 4548 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{printSpMatrix}\alias{printSpMatrix}\title{Print Sparse Matrices Flexibly}\description{Print sparse matrices flexibly. This is the \dQuote{workhorse} used bythe \code{\link{show}} and \code{\link{print}} methods for sparsematrices.}\usage{printSpMatrix(x, digits = getOption("digits"), maxp = getOption("max.print"),zero.print = ".",col.names, note.dropping.colnames = TRUE,col.trailer = "", align = c("fancy", "right"))}\arguments{\item{x}{an \R object inheriting from class \code{\linkS4class{sparseMatrix}}.}\item{digits}{significant digits to use for printing, see\code{\link{print.default}}.}\item{maxp}{integer, default from \code{\link{options}(max.print)},influences how many entries of large matrices are printed at all.}\item{zero.print}{character which should be printed for\emph{structural} zeroes. The default \code{"."} may occasionallybe replaced by \code{" "} (blank); using \code{"0"} would lookalmost like \code{print()}ing of non-sparse matrices.}\item{col.names}{logical or string specifying if and how column names of\code{x} should be printed, possibly abbreviated. The default istaken from \code{\link{options}("sparse.colnames")} if that is set, otherwise\code{FALSE} unless there are less than ten columns. When\code{TRUE} the full column names are printed.\crWhen \code{col.names} is a string beginning with \code{"abb"} or\code{"sub"} and ending with an integer \code{n} (i.e., of the form\code{"abb... <n>"}),the column names are \code{\link{abbreviate}()}d or\code{\link{substring}()}ed to (target) length \code{n}, see the examples.}\item{note.dropping.colnames}{logical specifying, when \code{col.names} is \code{FALSE}if the dropping of the column names should be noted, \code{TRUE} by default.}\item{col.trailer}{a string to be appended to the right of eachcolumn; this is typically made use of by \code{\link{show}(<sparseMatrix>)}only, when suppressing columns.}\item{align}{a string specifying how the \code{zero.print} codesshould be aligned, i.e., padded as strings. The default,\code{"fancy"}, takes some effort to align the typical\code{zero.print = "."} with the decimal points of the numbersprinted, whereas \code{align = "right"} just makes use of\code{\link{print}(*, right = TRUE)}.}}% \details{%% }\value{returns \code{x} \emph{invisibly}, see \code{\link{invisible}}.}\author{Martin Maechler}\seealso{the virtual class \code{\linkS4class{sparseMatrix}} and theclasses extending it; maybe \code{\link{spMatrix}} as a simpleconstructor of such matrices.}\examples{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 columnsX2 <- 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 fitt(X2) # suppressing column namesprint(t(X2), col.names=TRUE)print(t(X2), zero.print = "", col.names="abbr. 1")print(t(X2), zero.print = "-", col.names="substring 2")\dontshow{% show() was slow in 0.9975-8 because of slow adjust="fancy"op <- options(max.print = 25000, width = 80)sink(print(tempfile()))M <- Matrix(0, 10000, 100)M[1,1] <- M[2,3] <- 3.14stopifnot((st <- system.time(show(M)))[1] < 1.0) # only 0.09 on cmath-3sink()stoptions(op)}}\keyword{print}