> On 1/29/06, context grey <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> Is there something like a hashtable or (python)
>> dictionary in R/Splus?
On 29 Jan 2006, [EMAIL PROTECTED] wrote:
> use a 'list':
Most of the time, a list will be what you want, but it has some
important differences from a Python dictionary. In particular, one
can end up with duplicate keys. Here is an example:
h <- list()
h[["foo"]] <- 1
h[[2]] <- 2
names(h) <- rep("foo", 2)
h
$foo
[1] 1
$foo
[1] 2
h[["foo"]]
[1] 1
'environments' may be what you are looking for, see help for new.env().
h <- new.env(hash=TRUE)
An important thing to keep in mind with environments, however, is that
they are an exception to the pass by value semantics of the language.
Environments are not copied when passed as function args. This has
its uses, but can be confusing.
+ seth
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html