fastMatMR
is an R package that provides high-performance
reading and writing of Matrix Market files. It wraps around the fast_matrix_market
C++ library, ensuring optimal performance.
Performance vignettes for write and read operations are also provided.
Unlike other packages, such as Matrix
,
fastMatMR
offers extended support for:
.mtx
files..mtx
files.For performance benchmarks, see performance our vignettes for write and read operations.
To install the development version of fastMatMR
from
GitHub:
Load the fastMatMR
package:
fastMatMR
will correctly roundtrip NaN
values.NA
values are not supported by the Matrix Market
format, and are coerced to NaN
Sparse matrices can be written and read by the Matrix
library:
spmat <- Matrix::Matrix(c(1, 0, 3, NA), nrow = 2, sparse = TRUE)
temp_file_sp_na <- tempfile(fileext = ".mtx")
Matrix::writeMM(spmat, temp_file_sp_na)
Matrix::readMM(temp_file_sp_na)
## NULL
## 2 x 2 sparse Matrix of class "dgTMatrix"
## [1,] 1 3e+00
## [2,] . 1e+308
However, as can be seen above, NA
values are handled
incorrectly, and cause overflow. Dense matrices or vectors cannot be
read or written in the matrix market format by the Matrix
library.