NaArray-Compare-methods | R Documentation |
EXPERIMENTAL!!!
NaArray objects support all operations from the Compare
group.
See ?S4groupGeneric
in the methods package
for more information about the Compare
group generic.
Three forms of 'Compare' operations involving NaArray objects are supported:
Between an NaArray object naa
and a single
value y
:
naa op y y op naa
Between two NaArray objects naa1
and naa2
of same dimensions (a.k.a. conformable arrays):
naa1 op naa2
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
An NaArray object of type()
"logical"
and same
dimensions as the input object(s).
S4groupGeneric
in the methods package.
NaArray objects.
SVT_SparseArray objects.
Ordinary array objects in base R.
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)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.