This function takes different types of numeric inputs—vectors, matrices, and sparse matrices— and converts them into Matrix Market files. The output file is written to disk.
Examples
vec <- c(1, 2, 3)
mat <- matrix(c(1, 2, 3, 4), nrow = 2)
sparse_mat_diag <- Matrix::Matrix(c(1, 0, 0, 2), nrow = 2, sparse = TRUE)
## Diagonal ^-
sparse_mat <- Matrix::Matrix(c(1, 1, 0, 2), nrow = 2, sparse = TRUE)
## And not diagonal -^
write_fmm(vec, tempfile(fileext = ".mtx"))
#> [1] TRUE
write_fmm(mat, tempfile(fileext = ".mtx"))
#> [1] TRUE
write_fmm(sparse_mat_diag, tempfile(fileext = ".mtx"))
#> [1] TRUE
write_fmm(sparse_mat, tempfile(fileext = ".mtx"))
#> [1] TRUE