A big.matrix consists of an object in R that does little more than point to
the data structure implemented in C++. The object acts
much like a traditional R matrix, but helps protect the user from many inadvertant
memory-consuming pitfalls of traditional R matrices and data frames.Four atomic types are implemented (see argument type, above) to
help provide memory efficiency in different applications: double
(equivalent to numeric in R), integer (using 4 bytes), short
(using 2 bytes), and char (using a single byte).
If x is a big.matrix, then x[1:5,] is returned as an R
matrix containing the first five rows of x. If x is of type
double, then the result will be numeric; otherwise, the result will
be an integer R matrix. The expression x alone
will display information about the R object (e.g. the type) rather than evaluating the
matrix itself (the user should try x[,] with extreme caution,
recognizing that a huge R matrix will be created).
If x has a huge number of rows, then the use of rownames
will be extremely memory-intensive and should be avoided. If x has a huge
number of columns, the user might want to store the transpose as there is
overhead of a pointer for each column in the matrix.
Finally, when a big.matrix, x, is passed as an argument
to a function, it is essentially providing call-by-reference rather than
call-by-value behavior. If the function modified any of the values of x
within the function, the changes are not limited in scope to
a local copy within the function.