SparseArray-Compare-methods | R Documentation |
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.
Two forms of 'Compare' operations are supported:
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
.
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:
!=
, <
, >
.
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 <- 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)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.