[Rd] Associative array?

From: Ben <misc7_at_emerose.org>
Date: Thu, 11 Mar 2010 07:52:12 -0600


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.

729qlink3"><a name="0729qlink3">ame="0729qlink3">name="0729qlink3"> name="0729qlink3"><a name="0729qlink3">ame="0729qlink3">I found the hash package on CRAN:

    http://cran.r-project.org/web/packages/hash/index.html

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.

Thanks,

-- 
Ben

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu 11 Mar 2010 - 13:54:14 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 Thu 11 Mar 2010 - 17:21:03 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.

list of date sections of archive