NaArray | R Documentation |
EXPERIMENTAL!!!
Like SVT_SparseArray objects but the background value is NA
instead of zero.
## Constructor function:
NaArray(x, dim=NULL, dimnames=NULL, type=NA)
x |
If If |
dim |
|
dimnames |
The dimnames of the object to construct. Must be |
type |
A single string specifying the requested type of the object. By default the NaArray object returned by the constructor
function will have the same naa <- NaArray(x, type=type) is equivalent to doing: naa <- NaArray(x) type(naa) <- type but the former is more convenient and will generally be more efficient. The supported types for NaArray objects are |
NaArray is a concrete subclass of the Array virtual class. This makes NaArray objects Array derivatives.
Like with SVT_SparseArray objects, the non-NA data in an NaArray
object is stored in a Sparse Vector Tree.
See ?SVT_SparseArray
for more information.
An NaArray or NaMatrix object.
The SVT_SparseArray class.
is_nonna for is_nonna()
and nna*()
functions
nnacount()
, nnawhich()
, etc...
NaArray_aperm for permuting the dimensions of an NaArray object (e.g. transposition).
NaArray_subsetting for subsetting an NaArray object.
NaArray_abind for combining 2D or multidimensional NaArray objects.
NaArray_summarization for NaArray summarization methods.
NaArray_Arith, NaArray_Compare, and
NaArray_Logic, for operations from the Arith
,
Compare
, and Arith
groups on NaArray objects.
NaArray_Math for operations from the Math
and
Math2
groups on NaArray objects.
NaArray_misc for miscellaneous operations on an NaArray object.
NaArray_matrixStats for col/row summarization methods for NaArray objects.
Ordinary array objects in base R.
## ---------------------------------------------------------------------
## Display details of class definition & known subclasses
## ---------------------------------------------------------------------
showClass("NaArray")
## ---------------------------------------------------------------------
## The NaArray() constructor
## ---------------------------------------------------------------------
naa1 <- NaArray(dim=5:3) # all-NA object
naa1
naa2 <- NaArray(dim=c(35000, 2e6), type="integer") # all-NA object
naa2
## Add some non-NA values to 'naa2':
naa2[cbind( 1:99, 2:100)] <- 1L
naa2[cbind(1:100, 1:100)] <- 0L
naa2[cbind(2:100, 1:99)] <- -1L
naa2
## The dimnames can be specified at construction time, or
## added/modified later:
naa3 <- NaArray(c(NA, NA, 1L, NA, 0:7, rep(NA, 4), 12:14, NA),
dim=4:5, dimnames=list(letters[1:4], LETTERS[1:5]))
naa3
colnames(naa3) <- LETTERS[22:26]
naa3
## Sanity checks:
stopifnot(
is(naa1, "NaArray"),
identical(dim(naa1), 5:3),
identical(as.array(naa1), array(dim=5:3)),
is(naa2, "NaMatrix"),
all.equal(dim(naa2), c(35000, 2e6)),
identical(nnacount(naa2), 298L),
is(naa3, "NaMatrix"),
identical(dim(naa3), 4:5),
identical(nnacount(naa3), 12L)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.