Description Usage Arguments Value Methods Author(s) See Also
filematrix
is a class for working with very large matrices
stored in files, not held in computer memory.
It is intended as a simple, efficient solution to handling big numeric data
(i.e., datasets larger than memory capacity) in R.
A new filematrix can be created with fm.create
.
It can be created from an existing R matrix
with fm.create.from.matrix
.
A text file with a matrix can be scanned and converted into a filematrix
with fm.create.from.text.file
.
An existing filematrix can be opened for read/write access
with fm.open
or loaded fully in memory
with fm.load
.
A filematrix can be handled as an ordinary matrix in R.
It can be read from and written to via usual indexing
with possible omission of indices.
For example: fm[1:3,2:4]
and fm[,2:4]
.
The values can also be accessed as a vector
with single indexing.
For example: fm[3:7]
and fm[4:7] = 1:4
.
A whole filematrix can be read memory as an ordinary R matrix
with as.matrix
function or empty indexing fm[]
.
The dimensions of filematrix can be obtained via dim
,
nrow
and ncol
functions and
modified with dim
function.
For example: dim(fm)
and dim(fm) = c(10,100)
.
The number of elements in filematrix is returned by length
function.
A filematrix can have row and column names.
They can be accessed using the standard functions
rownames
, colnames
, and dimnames
.
A filematrix can be closed after use with close
command.
Note, however, that there is no risk of losing modifications
to a filematrix if an object is not closed,
as all changes are written to disk without delay.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## S3 method for class 'filematrix'
x[i,j]
## S3 replacement method for class 'filematrix'
x[i,j] <- value
## S4 method for signature 'filematrix'
as.matrix(x)
## S4 method for signature 'filematrix'
dim(x)
## S4 replacement method for signature 'filematrix'
dim(x) <- value
## S4 method for signature 'filematrix'
length(x)
## S4 method for signature 'filematrix'
rownames(x)
## S4 replacement method for signature 'filematrix'
rownames(x) <- value
## S4 method for signature 'filematrix'
colnames(x)
## S4 replacement method for signature 'filematrix'
colnames(x) <- value
## S4 method for signature 'filematrix'
dimnames(x)
## S4 replacement method for signature 'filematrix'
dimnames(x) <- value
|
x |
A filematrix object ( |
i,j |
Row/column indices specifying elements to extract or replace. |
value |
A new value to replace the indexed element(s). |
length
function returns the number of elements in the filematrix.
Functions colnames
, rownames
, and dimnames
return
the same values as their counterparts for the regular R matrices.
isOpen
Returns TRUE
is the filematrix is open.
readAll()
: Return the whole matrix.
Same as fm[]
or as.matrix(fm)
writeAll(value)
:Fill in the whole matrix.
Same as fm[] = value
readSubCol(i, j, num)
:Read num
values in column j
starting with row i
.
Same as fm[i:(i+num-1), j]
writeSubCol(i, j, value)
:Write values in the column j
starting with row i
.
Same as fm[i:(i+length(value)-1), j] = value
readCols(start, num)
:Read num
columns starting with column start
.
Same as fm[, start:(start+num-1)]
writeCols(start, value)
:Write columns starting with column start
.
Same as fm[, start:(start+ncol(value)-1)] = value
readSeq(start, len)
:Read len
values from the matrix starting with
start
-th value.
Same as fm[start:(start+len-1)]
writeSeq(start, value)
:Write values in the matrix starting with start
-th value.
Same as fm[start:(start+length(value)-1)] = value
appendColumns(mat)
Increases filematrix by adding columns to the right side of the matrix.
Matrix mat
must have the same number of rows.
Same as fm = cbind(fm, mat)
for ordinary matrices.
Andrey A Shabalin andrey.shabalin@gmail.com
For function creating and opening file matrices see
fm.create
.
Run browseVignettes("filematrix")
for the list of vignettes.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.