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

SparseArray-Logic-methodsR Documentation

'Logic' operations on SparseArray objects

Description

SparseArray derivatives support operations from the Logic group (i.e. & and |), with some restrictions. See ?S4groupGeneric in the methods package for more information about the Logic group generic.

IMPORTANT NOTES:

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

  • In base R, Logic operations support input of type() "logical", "integer", "double", or "complex". However, the corresponding methods for SVT_SparseArray objects only support objects of type() "logical" for now.

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 <- svt2 <- SVT_SparseArray(dim=c(15, 6))
svt1[cbind(1:15, 2)] <- c(TRUE, FALSE, NA)
svt1[cbind(1:15, 5)] <- c(TRUE, NA, NA, FALSE, TRUE)
svt2[c(2, 6, 12:17, 22:33, 55, 59:62, 90)] <- c(TRUE, NA)

svt1 & svt2
svt1 | svt2

## Sanity checks:
m1 <- as.matrix(svt1)
m2 <- as.matrix(svt2)
stopifnot(
  identical(as.matrix(svt1 & svt2), m1 & m2),
  identical(as.matrix(svt1 | svt2), m1 | m2)
)

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