printSpMatrix             package:Matrix             R Documentation

_P_r_i_n_t _S_p_a_r_s_e _M_a_t_r_i_c_e_s _F_l_e_x_i_b_l_y

_D_e_s_c_r_i_p_t_i_o_n:

     Print sparse matrices flexibly. These are the "workhorses" used by
     the 'show' and 'print' methods for sparse matrices.  If 'x' is
     large, 'printSpMatrix2(x)' calls 'printSpMatrix()' twice, namely,
     for the first and the last few rows, suppressing those in between,
     and also suppresses columns when 'x' is too wide.

_U_s_a_g_e:

     printSpMatrix(x, digits = getOption("digits"), maxp = getOption("max.print"),
                   zero.print = ".", col.names, note.dropping.colnames = TRUE,
                   col.trailer = "",
                   align = c("fancy", "right"))

     printSpMatrix2(x, digits = getOption("digits"), maxp = getOption("max.print"),
                   zero.print = ".", col.names, note.dropping.colnames = TRUE,
                   suppRows = NULL, suppCols = NULL,
                   col.trailer = if(suppCols) "......" else "",
                   align = c("fancy", "right"))

_A_r_g_u_m_e_n_t_s:

       x: an R object inheriting from class 'sparseMatrix'.

  digits: significant digits to use for printing, see 'print.default'.

    maxp: integer, default from 'options(max.print)', influences how
          many entries of large matrices are printed at all.

zero.print: character which should be printed for _structural_ zeroes. 
          The default '"."' may occasionally be replaced by '" "'
          (blank); using '"0"' would look almost like 'print()'ing of
          non-sparse matrices.

col.names: logical or string specifying if and how column names of 'x'
          should be printed, possibly abbreviated.  The default is
          taken from 'options("sparse.colnames")' if that is set,
          otherwise 'FALSE' unless there are less than ten columns. 
          When 'TRUE' the full column names are printed.
           When 'col.names' is a string beginning with '"abb"' or
          '"sub"' and ending with an integer 'n' (i.e., of the form
          '"abb... <n>"'), the column names are 'abbreviate()'d or
          'substring()'ed to (target) length 'n', see the examples. 

note.dropping.colnames: logical specifying, when 'col.names' is 'FALSE'
          if the dropping of the column names should be noted, 'TRUE'
          by default.

col.trailer: a string to be appended to the right of each column; this
          is typically made use of by 'show(<sparseMatrix>)' only, when
          suppressing columns.

suppRows, suppCols: logicals or 'NULL', for 'printSpMatrix2()'
          specifying if rows or columns should be suppressed in
          printing.  If 'NULL', sensible defaults are determined from
          'dim(x)' and 'options(c("width", "max.print"))'. Setting both
          to 'FALSE' may be a very bad idea.

   align: a string specifying how the '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 numbers printed,  whereas
          'align = "right"' just makes use of 'print(*, right = TRUE)'. 

_V_a_l_u_e:

     returns 'x' _invisibly_, see 'invisible'.

_A_u_t_h_o_r(_s):

     Martin Maechler

_S_e_e _A_l_s_o:

     the virtual class 'sparseMatrix' and the classes extending it; 
     maybe 'spMatrix' as a simple constructor of such matrices.

_E_x_a_m_p_l_e_s:

     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")

