JWriteBin | R Documentation |
Writes a R matrix to a disk file as a binary matrix in the jmatrix format
JWriteBin(M, fname, dtype = "float", dmtype = "full", comment = "")
M |
The R matrix to be written |
fname |
The name of the file to write |
dtype |
The data type of the matrix to be written: one of the strings 'short', 'int', 'long', 'float' or 'double'. Default: 'float' |
dmtype |
The matrix type: one of the strings 'full', 'sparse' or 'symmetric'. Default: 'full' |
comment |
A optional string with the comment to be added as metadata. Default: "" (empty string, no added comment) |
Use this function cautiously. Differently to the functions to get one or more rows or columns from the binary file,
which book only the memory strictly needed for the vector/matrix and do not load all the binary file in memory,
this function books the full matrix in the requested data type and writes it later so with very big matrices
you might run out of memory.
Type 'int' is really long int (8-bytes in most modern machines) so using 'int' or 'long' is equivalent.
Type is coerced from double (the internal type of R matrices) to the requested type, which may provoke a loose of precision.
If M is a named-R matrix, row and column names are written as metadata, too.
Also, if you write as symmetric a matrix which is not such, only the lower-diagonal part will be written.
The rest of the data will be lost. In this case, if the matrix has row and column names, only row names are written.
No return value, called for side effects (creates a file)
Rf <- matrix(runif(48),nrow=6)
rownames(Rf) <- c("A","B","C","D","E","F")
colnames(Rf) <- c("a","b","c","d","e","f","g","h")
tmpfile1=paste0(tempdir(),"/Rfullfloat.bin")
JWriteBin(Rf,tmpfile1,dtype="float",dmtype="full",comment="Full matrix of floats")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.