show: Quick Glance at Sparse Objects

Description Usage Arguments Value Examples

Description

Shows some basic information about a sparse matrix or sparse vector object, without printing a subset of its entries as 'Matrix' would do.

Note that this package will by default override the 'show' methods of sparse objects, but not the ‘print' methods - for example, if one defines a variable ’X' containing a sparse matrix, and then types 'X' in the console, that calls the 'show' method, but one can still print it by calling 'print(X)'.

In order to restore the 'show' method provided by 'Matrix', call 'options("MatrixExtra.quick_show" = FALSE)'.

Usage

1
2
3
4
5
6
7
8
## S4 method for signature 'sparseMatrix'
show(object)

## S4 method for signature 'sparseVector'
show(object)

## S4 method for signature 'sparseVector'
print(x)

Arguments

object

A sparse matrix or sparse vector.

x

A sparse vector (same method as in matrix, readded here to avoid naming conflicts).

Value

The same object that was passed as input, as invisible.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(Matrix)
library(MatrixExtra)

set.seed(1)
X <- Matrix::rsparsematrix(5, 5, .2)
set_new_matrix_behavior()
show(X)
print(X)
X

restore_old_matrix_behavior()
show(X)
print(X)
X

MatrixExtra documentation built on Dec. 19, 2021, 9:07 a.m.