Description Usage Arguments Value Examples
View source: R/altWrapper-tools.R
This function can only be used on an altWrapper object.
The wrapper is an ALTREP object and created by R to automatically memorize
some statistics(e.g. sortness status). It can be silently added by some R functions and behaves
exactly the same as the object it wraps. This function can be called
in order to make sure the altWrapper variable x
is not wrapped by a wrapper,
1 |
x |
An altWrapper object |
An altWrapper object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Define an altWrapper class
lengthFunc <- function(x) length(x)
elementFunc <- function(x, i) x[i]
setAltClass(className = "example", classType = "integer")
setAltMethod(className = "example",
getLength = lengthFunc,
getElement = elementFunc)
A <- newAltrep(className = "example", x = 1L:10L)
## Wrap the variable A through an internal function
## Note that this can happenes in some R functions.
B <- .Internal(wrap_meta(A, sorted = 0L, noNA = TRUE))
.Internal(inspect(B))
## Although the variable B still behaves like the variable A
## Calling `getAltWrapperData` will show an error because the object
## is not an altWrapper
tryCatch(getAltWrapperData(B), error = function(e) message(e))
## Call `removeCachingWrapper` to remove R's wrapper
C <- removeCachingWrapper(B)
getAltWrapperData(C)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.