Learn R Programming

houba (version 0.1.0)

marray: Creation of memory mapped objects

Description

These functions create memory mapped vectors, matrices or arrays, possibly from an existing file.

Usage

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 )

Value

a memory mapped object, of class 'mvector', 'mmatrix' or 'marray'

Arguments

datatype

the data type

dim

dimension of marray

filename

(optional) path to file

readonly

(optional) if TRUE, the object will be read-only.

nrow

number of rows of mmatrix

ncol

number of columns of mmatrix

length

length of mvector

Details

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. In the contrary case, is 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.

Examples

Run this code
a <- mmatrix("float", 4, 3)
a[] <- 1:12
a[1,]

Run the code above in your browser using DataLab