From misc7 at emerose.org  Thu Mar 11 14:52:12 2010
From: misc7 at emerose.org (Ben)
Date: Thu, 11 Mar 2010 07:52:12 -0600
Subject: [Rd] Associative array?
Message-ID: <20100311075212.66a6a0e7.misc7@emerose.org>

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:

    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



[Rd] Associative array?
Ben