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

NaArray-Compare-methodsR Documentation

'Compare' operations on NaArray objects

Description

EXPERIMENTAL!!!

NaArray objects support all operations from the Compare group. See ?S4groupGeneric in the methods package for more information about the Compare group generic.

Details

Three forms of 'Compare' operations involving NaArray objects are supported:

  1. Between an NaArray object naa and a single value y:

        naa op y
        y op naa
  2. Between two NaArray objects naa1 and naa2 of same dimensions (a.k.a. conformable arrays):

        naa1 op naa2
  3. Between an NaArray object naa and an SVT_SparseArray object svt of same dimensions (a.k.a. conformable arrays):

        naa op svt
        svt op naa

Value

An NaArray object of type() "logical" and same dimensions as the input object(s).

See Also

  • S4groupGeneric in the methods package.

  • NaArray objects.

  • SVT_SparseArray objects.

  • Ordinary array objects in base R.

Examples

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

nam1 >= 0.2
nam1 != 0

nam2 <- NaArray(dim=dim(nam1), type="integer")
nam2[cbind(1:15, 2)] <- 100:114
nam2[cbind(1:15, 5)] <- -(114:100)
nam2

nam1 < nam2

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

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