Skip to content

hashing using named lists

2 messages · Huntsinger, Reid, Brian Ripley

#
It seems that that behavior is hard-coded in the subscript code, 
but I bet you could fix it easily by changing the call to get1index

 offset = get1index(CAR(subs), getAttrib(x, R_NamesSymbol),
                           length(x), /*partial ok*/TRUE, i);

in src/main/subset.c (line 762 I think, R-2.0.0) to supply FALSE in place of
TRUE and recompiling... I haven't tried yet though so maybe I'm quite badly
wrong.

Reid Huntsinger 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of ulas karaoz
Sent: Thursday, November 18, 2004 11:30 AM
To: r-help at stat.math.ethz.ch
Subject: [R] hashing using named lists


hi all,
I am trying to use named list to hash a bunch of vector by name, for 
instance:
test = list()
test$name = c(1,2,3)

the problem is that when i try to get the values back by using the 
name, the matching isn't done in an exact way, so
test$na is not NULL.

is there a way around this?
Why by default all.equal.list doesnt require an exact match?
How can I do hashing in R?

thanks.
ulas.

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
#
On Thu, 18 Nov 2004, Huntsinger, Reid wrote:

            
the behaviour being partial matching?
That is the [[ ]] code.  The $ code is at about line 968.

And if you did that a lot of R code may break, so please don't even think 
about it.  Partial matching is a long-standing feature.

There have been proposals from time to time for [ ] and [[ ]] to have an 
exact=TRUE argument for character indices.  That seems a good idea, except 
that they are generic and there are now many methods out there which would 
ignore the argument.