This package provides two types of objects:
- externalVector: a class of objects that behave like R vectors but are stored
in a resource outside R.
- externalStorage: the class of objects representing storage external tw R.
One implementation of externalStorage is provided in this package. It is
called simpleStorage and it uses R itself to allocate the memory for the
objects.
To create an externalVector object, use one of the functions externalVector
externalInteger, externalNumeric, externalComplex, externalCharacter
or externalLogical. The behaviour of these functions are similar to
vector, integer, numeric etc. that come with R.
Eventually many of the R operations valid for vector objects will be
available for external vectors. Most of the basic operations are supported
now including subsetting, assignment, arithmetic and relation operations
and some mathematical functions like sin, cos or exp.
You can also create an external matrix by first creating an external
vector and then setting its dimension.
x <- externalNumeric(12)
x[] <- rnorm(12)
dim(x) <- c(3, 4)
You can also use the equivalent of the matrix function.
x <- externalMatrix(rnorm(12), nrow=3)
Matrix subsetting is supported.
x[1:2, 3:4]
x[1, 1] <- 100
x
Some functions like colSums or rowSums which are specific to matrices
(or arrays) is also supported. Support for arrays (i.e. any external vector
X with length(dim(X)) > 2) is not explicitly supported right now - although
you can certainly create them by setting the appropriate dimension.
Currently the storage for external vector objects is passed by reference and is
never copied. So if you further do
y <- x
y[1, 1] <- 0
x[1, 1] == 0 # returns TRUE
you would see that x[1, 1] and y[1, 1] have same values. In future we
will provide externalVector classes which use different copy semantics.