Forum: developers


Segments with S4 classes [ Reply ] By: Peter Solymos on 2011-01-29 05:30 | [forum:3926] |
Since >2 dimensional sparse arrays are not yet implemented in Matrix, it is a challenge to simply allowing segments in mefa4. A segmented representation would however be very useful as I just learned today with a data manipulation task. Here is a conceptual overview of how to do it. 1) Use some modifications of Xtab to create a list of sparse matrices, one for each segment. 2) create union set for dimnames, and also a fully sparse (sum = 0) matrix with the union dimnames. 3) use mbind on each segment and order rows/columns. Later, possibly keep only one copy of dimnames to save space, and define an S4 class (sparseSegm or so, reserve sparseArray class for D Bates). Maybe add segm slot for corresponding Mefa objects? Also this will need [ and [<- etc. |