Matrix-class {Matrix}R Documentation

Virtual Class "Matrix" Class of Matrices

Description

The Matrix class is a class contained by all actual classes in the Matrix package. It is a “virtual” class.

Slots

Common to all matrix objects in the package:

Dim:
Object of class "integer" - the dimensions of the matrix - must be an integer vector with exactly two non-negative values.
Dimnames:
list of length two; each component containing NULL or a character vector length equal the corresponding Dim element.

Methods

dim
signature(x = "Matrix"): extract matrix dimensions dim.
dimnames
signature(x = "Matrix"): extract dimnames.
dimnames<-
signature(x = "Matrix", value = "list"): set the dimnames to a list of length 2, see dimnames<-.
show
signature(object = "Matrix"): show method for printing.
head
signature(object = "Matrix"): return only the “head”, i.e., the first few rows.
tail
signature(object = "Matrix"): return only the “tail”, i.e., the last few rows of the respective matrix.

as.matrix, as.array
signature(x = "Matrix"): the same as as(x, "matrix"); see also the note below.
as.vector
signature(x = "Matrix", mode = "missing"): as.vector(m) should be identical to as.vector(as(m, "matrix")), implemented more efficiently for some subclasses.

There are many more methods that (conceptually should) work for all "Matrix" objects, e.g., colSums, rowMeans. Even base functions may work automagically (if they first call as.matrix() on their principal argument), e.g., apply, eigen, svd or kappa all do work via coercion to a “traditional” (dense) matrix.

Note

Loading the Matrix namespace “overloads” as.matrix and as.array in the base namespace by the equivalent of function(x) as(x, "matrix"). Consequently, as.matrix(m) or as.array(m) will properly work when m inherits from the "Matrix" class — also for functions in package base and other packages. E.g., apply or outer can therefore be applied to "Matrix" matrices.

Author(s)

Douglas Bates bates@stat.wisc.edu and Martin Maechler

See Also

the classes dgeMatrix, dgCMatrix, and function Matrix for construction (and examples).

Examples

slotNames("Matrix")

cl <- getClass("Matrix")
names(cl@subclasses) # more than 40 ..

showClass("Matrix")#> output with slots and all subclasses

[Package Matrix version 0.9975-6 Index]