DelayedSubset-class | R Documentation |
NOTE: This man page is about DelayedArray internals and is provided for developers and advanced users only.
The DelayedSubset class provides a formal representation of a delayed multi-dimensional single bracket subsetting operation. It is a concrete subclass of the DelayedUnaryOp virtual class, which itself is a subclass of the DelayedOp virtual class:
DelayedOp ^ | DelayedUnaryOp ^ | DelayedSubset
DelayedSubset objects are used inside a DelayedArray object to represent the delayed multi-dimensional single bracket subsetting operations carried by the object. They're never exposed to the end user and are not intended to be manipulated directly.
## S4 method for signature 'DelayedSubset'
is_noop(x)
## S4 method for signature 'DelayedSubset'
summary(object, ...)
## ~ ~ ~ Seed contract ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
## S4 method for signature 'DelayedSubset'
dim(x)
## S4 method for signature 'DelayedSubset'
dimnames(x)
## S4 method for signature 'DelayedSubset'
extract_array(x, index)
## ~ ~ ~ Propagation of sparsity ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
## S4 method for signature 'DelayedSubset'
is_sparse(x)
## S4 method for signature 'DelayedSubset'
extract_sparse_array(x, index)
x , object |
A DelayedSubset object. |
index |
See |
... |
Not used. |
DelayedOp objects.
showtree
to visualize the nodes and access the
leaves in the tree of delayed operations carried by a
DelayedArray object.
extract_array in the S4Arrays package.
extract_sparse_array
in the
SparseArray package.
## DelayedSubset extends DelayedUnaryOp which extends DelayedOp:
extends("DelayedSubset")
## ---------------------------------------------------------------------
## BASIC EXAMPLE
## ---------------------------------------------------------------------
a0 <- array(1:60, dim=5:3)
A0 <- DelayedArray(a0)
showtree(A0)
A <- A0[2:1, -4, 3, drop=FALSE]
showtree(A)
class(A@seed) # a DelayedSubset object
## ---------------------------------------------------------------------
## PROPAGATION OF SPARSITY
## ---------------------------------------------------------------------
sm0 <- sparseMatrix(i=c(1, 4), j=c(1, 3), x=c(11, 43), dims=4:3)
SM0 <- DelayedArray(sm0)
showtree(SM0)
is_sparse(SM0) # TRUE
SM1 <- SM0[-1, 3:2, drop=FALSE]
showtree(SM1)
class(SM1@seed) # a DelayedSubset object
is_sparse(SM1@seed) # TRUE
## Duplicated indices break structural sparsity.
M2 <- SM0[-1, c(3:2, 2), drop=FALSE]
showtree(M2)
class(M2@seed) # a DelayedSubset object
is_sparse(M2@seed) # FALSE
## ---------------------------------------------------------------------
## SANITY CHECKS
## ---------------------------------------------------------------------
stopifnot(class(A@seed) == "DelayedSubset")
stopifnot(class(SM1@seed) == "DelayedSubset")
stopifnot(is_sparse(SM1@seed))
stopifnot(class(M2@seed) == "DelayedSubset")
stopifnot(!is_sparse(M2@seed))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.