I have a sparse matrix whose rows and columns names are numbers. I need to sort rows and columns so that they are increasing. However, dimnames can only be stored as characters, not integers or numbers, so that sorting dimnames does not give increasing sorting but rather treats numbers as words and sorts them alphabetically (for example, 10000001 comes before 1001).
Every time I try to change the type of the dimnames I get this error:
Error in dimnamesGets(x, value) :
invalid dimnames given for “dgCMatrix” object
Is there a way around this? Are there different types of matrices that allow for numerical dimnames?