SparseArray-Compare-methods: 'Compare' operations on SparseArray objects

SparseArray-Compare-methodsR Documentation

'Compare' operations on SparseArray objects

Description

SparseArray derivatives support operations from the Compare group, with some restrictions. See ?S4groupGeneric in the methods package for more information about the Compare group generic.

IMPORTANT NOTE: Only SVT_SparseArray objects are supported at the moment. Support for COO_SparseArray objects might be added in the future.

Details

Two forms of 'Compare' operations are supported:

  1. Between an SVT_SparseArray object svt and a single value y:

        svt op y
        y op svt

    All operations from the Compare group support this form, with single value y either on the left or the right. However, there are some operation-dependent restrictions on the value of y.

  2. Between two SVT_SparseArray objects svt1 and svt2 of same dimensions (a.k.a. conformable arrays):

        svt1 op svt2

    The Compare operations that support this form are: !=, <, >.

Value

A SparseArray derivative of type() "logical" and same dimensions as the input object(s).

See Also

  • S4groupGeneric in the methods package.

  • SparseArray objects.

  • Ordinary array objects in base R.

Examples

svt1 <- SVT_SparseArray(dim=c(15, 6), type="double")
svt1[c(2, 6, 12:17, 22:33, 55, 59:62, 90)] <- runif(26)
svt1

svt1 >= 0.2
svt1 != 0

## Sanity checks:
m1 <- as.matrix(svt1)
stopifnot(
  identical(as.matrix(svt1 >= 0.2), m1 >= 0.2),
  identical(as.matrix(svt1 != 0), m1 != 0)
)

Bioconductor/SparseArray documentation built on Nov. 14, 2024, 6:22 p.m.