as.hi {ff} | R Documentation |
The generic as.hi
and its methods are the main (internal) means for preprocessing index information into the hybrid index class hi
.
Usually as.hi
is called transparently from [.ff
. However, you can explicitely do the index-preprocessing,
store the Hybrid Index hi
, and use the hi
for subscripting.
as.hi(x, ...) ## S3 method for class 'hi': as.hi(x, ...) ## S3 method for class 'call': as.hi(x, maxindex = NA, dim = NULL, dimorder = NULL, vw = NULL, vw.convert = TRUE, pack = TRUE, parents = 1, ...) ## S3 method for class 'name': as.hi(x, parents=1, ...) ## S3 method for class 'integer': as.hi(x, maxindex = NA, dim = NULL, dimorder = NULL, symmetric = FALSE, fixdiag = NULL, vw = NULL, vw.convert = TRUE, dimorder.convert = TRUE, pack = TRUE, NAs = NULL, ...) ## S3 method for class 'double': as.hi(x, ...) ## S3 method for class 'logical': as.hi(x, maxindex = NA, dim = NULL, vw = NULL, pack = TRUE, ...) ## S3 method for class 'character': as.hi(x, names, vw = NULL, vw.convert = TRUE, ...) ## S3 method for class 'matrix': as.hi(x, dim, maxindex = NA, dimorder = NULL, symmetric = FALSE, fixdiag = NULL, vw = NULL, pack = TRUE, ...)
x |
an appropriate object of the class for which we dispatched |
parents |
the number of frames to look up when evaluating components of the index expression |
maxindex |
maximum positive indexposition maxindex , is needed with negative indices, if vw or dim is given, maxindex is calculated automatically |
names |
the names of the indexed vector for character indexing |
dim |
the dim of the indexed matrix to be stored within the hi object |
dimorder |
the dimorder of the indexed matrix to be stored within the hi object, may convert interpretation of x |
symmetric |
the symmetric of the indexed matrix to be stored within the hi object |
fixdiag |
the fixdiag of the indexed matrix to be stored within the hi object |
vw |
the virtual window vw of the indexed vector or matrix to be stored within the hi object, see details |
vw.convert |
FALSE to prevent doubly virtual window conversion, this is needed for some internal calls that have done the virtual window conversion already, see details |
dimorder.convert |
FALSE to prevent doubly dimorder conversion, this is needed for some internal calls that have done the dimorder conversion already, see details |
NAs |
a vector of NA positions to be stored rlepacked , not fully supported yet |
pack |
FALSE to prevent rlepacking |
... |
further argument passed from generic to method or from wrapper method to as.hi.integer |
The generic dispatches appropriately, as.hi.hi
returns an hi
object unchanged,
as.hi.call
tries to hiparse
instead of evaluate its input in order to save RAM.
If parsing fails it evaluates the index expression and dispatches again to one of the other methods.
as.hi.name
and as.hi.(
are wrappers to as.hi.call
.
as.hi.integer
is the workhorse for coercing evaluated expressions,
as.hi.double
, as.hi.logical
and as.hi.character
are simply wrappers to as.hi.integer
,
but note that as.hi.logical
is not memory efficient because it expands all positions and then applies logical subscripting.
as.hi.matrix
calls arrayIndex2vectorIndex
and then as.hi.integer
to interpret and preprocess matrix indices.
If the dim
and dimorder
parameter indicate a non-standard dimorder (dimorderStandard
), the index information in x
is converted from a standard dimorder interpretation to the requested dimorder
.
If the vw
parameter is used, the index information in x
is interpreted relative to the virtual window but stored relative to the abolute origin.
Back-coercion via as.integer.hi
and friends will again return the index information relative to the virtual window, thus retaining symmetry and transparency of the viurtual window to the user.
You can use length
to query the index length (possibly length of negative subscripts),
length
to query the number of selected elements (even with negative subscripts),
and maxindex
to query the largest possible index position (within virtual window, if present)
Duplicated negative indices are removed and will not be recovered by as.integer.hi
.
an object of class hi
Avoid changing the Hybrid Index representation, this might crash the [.ff
subscripting
Jens Oehlschlägel
hi
for the Hybrid Index class, hiparse
for parsing details, as.integer.hi
for back-coercion, [.ff
for ff subscripting
cat("integer indexing with and without rel-packing\n") as.hi(1:12) as.hi(1:12, pack=FALSE) cat("if index is double, the wrapper method just converts to integer\n") as.hi(as.double(1:12)) cat("if index is character, the wrapper method just converts to integer\n") as.hi(c("a","b","c"), names=letters) cat("negative index must use maxindex (or vw)\n") as.hi(-(1:3), maxindex=12) cat("logical index can use maxindex\n") as.hi(c(FALSE, FALSE, TRUE, TRUE)) as.hi(c(FALSE, FALSE, TRUE, TRUE), maxindex=12) cat("matrix index\n") x <- matrix(1:12, 6) as.hi(rbind(c(1,1), c(1,2), c(2,1)), dim=dim(x)) cat("first ten positions within virtual window\n") i <- as.hi(1:10, vw=c(10, 80, 10)) i cat("back-coerce relativ to virtual window\n") as.integer(i) cat("back-coerce relativ to absolute origin\n") as.integer(i, vw.convert=FALSE) cat("parsed index expressions save index RAM\n") as.hi(quote(1:1000000000)) ## Not run: cat("compare to RAM requirement when the index experssion is evaluated\n") as.hi(1:1000000000) ## End(Not run) cat("example of parsable index expression\n") a <- seq(100, 200, 20) as.hi(substitute(c(1:5, 4:9, a))) hi(c(1,4, 100),c(5,9, 200), by=c(1,1,20)) cat("example of index expression partially expanded and accepting token\n") as.hi(quote(1+(1:16))) # non-supported use of brackets '(' and mathematical operators '+' expands 1:16, parsing is aborted because length>16 cat("example of index expression completely evaluated after token has been rejected\n") as.hi(quote(1+(1:17))) # non-supported use of brackets '(' and mathematical operators '+' expands 1:17, parsing is aborted because length>16