[Rd] Associative array?

Ben misc7 at emerose.org
Thu Mar 11 14:52:12 CET 2010

Hi, can someone tell me how to use associative arrays in R?  It can be
a hashtable or some kind of tree, as long as the lookups aren't O(n).
One way to do this is to use names, e.g. in:

    list(a=3, ...)[["a"]]

presumably looking up "a" is very quick.  (Can someone tell me offhand
how that is implemented?  Hashtable?)  However, if I wanted to, say,
memoize a numeric function, I can't elegantly use R names because R names must be characters.

I found the hash package on CRAN:


but it seems the keys are still characters.  Also, I haven't heard
anyone talking about it.  Trees and hashtables are common data
structures, so this problem must come up a lot.



More information about the R-devel mailing list