SparseArray-Logic-methods | R Documentation |
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.
A SparseArray derivative of type()
"logical"
and
same dimensions as the input object(s).
S4groupGeneric
in the methods package.
SparseArray objects.
Ordinary array objects in base R.
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)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.