In the last few years I have used a lot R's base library Matrix that has implementation of sparse matrix objects and efficient computations. To the sparse matrices from R's Matrix library one can assign and retrieve row names and column names with the functions colnames
and rownames
. Sometimes I miss this in Mathematica so I started a Mathematica package that implements similar functionalities. The package is named RSparseMatrix.m has purely Mathematica language implementations (i.e. it does not use RLink ). It can be loaded/downloaded from MathematicaForPrediction at GitHub:
Import["https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/Misc/RSparseMatrix.m"]
The package provides functions to create and do operations over RSparseMatrix
objects of that are basically SparseArray
objects with row and column names. A major design decision is to restrict these functionalities to two dimensional sparse arrays and lists of strings as row and column names. (Note that the package is not finished and in some functions the row and column names are ignored.)
The package attempts to cover as many as possible of the functionalities for sparse matrix objects that are provided by R's Matrix library. (Sub-matrix extraction by row and column names, row and column names propagation for dot products, row and column binding sparse matrices, row and column sums, etc.) This document has examples and tests for RSparseMatrix.m .
My participation in WTC 2015 with a talk about Mathematica and R comparison was one the main motivators to write about RSparseMatrix.m. I find RSparseMatrix.m helpful when communicating certain ideas with machine learning teams with heavy R adoption in them.
Here is an image with sub-matrix taking with using row names and column names: 
And here is image with examples of Dot products:

This blog post and this document have detailed usage examples and the following (attempt for a) neat example.
Consider this incidence matrix that represents a bi-partite graph of relationships of actors starring in movies: 
We can use an RSparseMatrix
object of it with named rows and columns (rBiMat
).
Here is the corresponding graph: 
If we want to see which actors have participated in movies together with Orlando Bloom we can do the following:
