| filematrix-class {filematrix} | R Documentation |
Manipulating file matrices (class "filematrix")
Description
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.
Usage
## 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
Arguments
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). |
Value
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.
Methods
isOpen-
Returns
TRUEis the filematrix is open. readAll():Return the whole matrix.
Same asfm[]oras.matrix(fm)writeAll(value):-
Fill in the whole matrix.
Same asfm[] = value readSubCol(i, j, num):-
Read
numvalues in columnjstarting with rowi.
Same asfm[i:(i+num-1), j] writeSubCol(i, j, value):-
Write values in the column
jstarting with rowi.
Same asfm[i:(i+length(value)-1), j] = value readCols(start, num):-
Read
numcolumns starting with columnstart.
Same asfm[, start:(start+num-1)] writeCols(start, value):-
Write columns starting with column
start.
Same asfm[, start:(start+ncol(value)-1)] = value readSeq(start, len):-
Read
lenvalues from the matrix starting withstart-th value.
Same asfm[start:(start+len-1)] writeSeq(start, value):-
Write values in the matrix starting with
start-th value.
Same asfm[start:(start+length(value)-1)] = value appendColumns(mat)-
Increases filematrix by adding columns to the right side of the matrix. Matrix
matmust have the same number of rows.
Same asfm = cbind(fm, mat)for ordinary matrices.
Author(s)
Andrey A Shabalin andrey.shabalin@gmail.com
See Also
For function creating and opening file matrices see
fm.create.
Run browseVignettes("filematrix") for the list of vignettes.