To upload a sparse matrix stored in Matrix Market format with the extension .mtx_cols in R, there are a few steps to follow:
main.r16 chars2 lines
readMM()
function to read in the Matrix Market file. This function automatically detects whether the file is in coordinate or array format, and whether it stores a dense or sparse matrix.main.r44 chars2 lines
as.matrix()
function can be used to convert from the Matrix class to a standard R matrix:main.r28 chars2 lines
Or, you can use one of the other functions provided by the Matrix package, such as as.csr()
to convert to compressed sparse row format:
main.r23 chars2 lines
That's it! Now your sparse matrix stored in the .mtx_cols file is loaded into R and ready for analysis.
gistlibby LogSnag