disordR package: an introduction to class
disindex
Experimental S4 class disindex allows
extraction methods, including list extraction, to operate with the
output of which(). Consider the following R session:
## A disord object with hash 78aeb8dd7637e225f68149b7d8693c2e8610780e and elements
## [1] 4 6 1 2 3 4 5 1
## (in some order)
Above, object ind points to those elements of
d which exceed 4. Thus:
## A disord object with hash 78aeb8dd7637e225f68149b7d8693c2e8610780e and elements
## [1] 4 6 1 2 3 4 5 1
## (in some order)
## A disord object with hash ea05c0cfada69ce31109e52505ad327bf09323b9 and elements
## [1] 6 5
## (in some order)
## A disord object with hash df9ea368b1387390e289036ddb4938e17b98fe12 and elements
## [1] 4 99 1 2 3 4 99 1
## (in some order)
However, we cannot assert that ind is elements 2 and 7
of d, for the elements of d are stored in an
implementation-specific order. If we examine ind directly,
we see:
## A disind object with hash 78aeb8dd7637e225f68149b7d8693c2e8610780e and 2 (implementation-specific) elements
which correctly says that the elements of ind are
implementation-specific. However, the main application of
disindex objects is for list extraction.
## A disord object with hash 05eee623f834041c7740a90732865f8828d5c84d and elements
## [[1]]
## [1] 5 4
##
## [[2]]
## [1] 5 4 3 2 1
##
## [[3]]
## [1] 5 6
##
## [[4]]
## [1] 5 4 3 2
##
## (in some order)
Suppose I wish to extract from object dl just the
element with the longest length. Noting that this would be a
disord-compliant question, we would use:
## [1] 5 4 3 2 1