These functions create memory mapped vectors, matrices or arrays,
possibly from an existing file. It is also possible to create objects in memory,
by passing the argument filename = "".
marray(
datatype = c("double", "float", "integer", "short"),
dim,
filename,
readonly
)mmatrix(
datatype = c("double", "float", "integer", "short"),
nrow,
ncol,
filename,
readonly
)
mvector(
datatype = c("double", "float", "integer", "short"),
length,
filename,
readonly
)
a memory mapped object, of class 'mvector', 'mmatrix' or 'marray'
the data type
dimension of marray
(optional) path to file
(optional) if TRUE, the object will be read-only.
number of rows of mmatrix
number of columns of mmatrix
length of mvector
Currently datatype can only be double, float, int, or short. Short will always be a 16 bits
integer (int16_t).
If filename is missing, a temporary filename will be generated using tempfile.
If it is an empty string, the object will be created by allocating memory.
Otherwise, filename must be a valid path file;
if the file exists, it will be opened (if its size is compatible with the dimension
of the object); if the file does not exist, it will be created.
If readonly is missing, it will be set to TRUE when opening an existing file, and
to FALSE when the file is created by the function.
a <- mmatrix("float", 4, 3)
a[] <- 1:12
a[1,]
Run the code above in your browser using DataLab