[R] hashing using named lists
Barry Rowlingson
B.Rowlingson at lancaster.ac.uk
Thu Nov 18 18:58:21 CET 2004
ulas karaoz wrote:
> is there a way around this?
yes...
> Why by default all.equal.list doesnt require an exact match?
because we're lazy? :)
> How can I do hashing in R?
you can explicitly test the names for equality, eg with this 2-element
list:
> x
$name
[1] 1 2 3
$n
[1] 3 2 1
You can do:
> x[names(x)=='name']
$name
[1] 1 2 3
> x[names(x)=='na']
list()
> x[names(x)=='n']
$n
[1] 3 2 1
Of course, the right way would be to create a new class, 'hash'
perhaps, that did all this in its '$' or '[' methods.
Baz
More information about the R-help
mailing list