[Rd] O(?) access time for rownames/colnames/named dimensions

From: mfrumin <michael_at_frumin.net>
Date: Fri, 03 Aug 2007 04:06:14 -0700 (PDT)

Dear princely R developers to whom I owe so much of my daily productivity level,

I am wondering how indexing by row and column names are implemented. That is, when I have a matrix with named rows (or columns) and I then index into that matrix using the string names (rather than integers), how does R scan through the list of names in order to figure out which row/column to use? My current suspicion is that it's a linear search, but I've been wrong many times before.

If it is linear, may I ask if the possibility of implementing the name-to-integer-index lookup in a more efficient way as ever been discussed? For example, why not hash the string indexes to quickly map them to integer indexes?

Of course adding this sort of functionality would make it somewhat more expensive to add rows/columns anywhere but the end of the matrix, but in many cases I suspect it would be worth it. Or perhaps there would be a way to enable this selectively on each named dimension?

In my use case, I am building an array with named dimensions once, and then doing lots of reading/updates into that matrix without changing its shape. This is proving to be rather costly at the moment and I've taken to using a hashed environment to do lookups where it really counts, but this is rather inconvenient.

I'm sure this has been thought about before, but I didn't see anything in this mailing list.


View this message in context: http://www.nabble.com/O%28-%29-access-time-for-rownames-colnames-named-dimensions-tf4211918.html#a11981293
Sent from the R devel mailing list archive at Nabble.com.

R-devel_at_r-project.org mailing list
Received on Fri 03 Aug 2007 - 20:01:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 04 Aug 2007 - 05:37:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.