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. This is the "workhorse" used by
     the 'show' and 'print' methods for sparse matrices.

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

_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.

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

