[R] hashing using named lists

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Nov 18 20:07:10 CET 2004


On Thu, 18 Nov 2004, Huntsinger, Reid wrote:

> It seems that that behavior is hard-coded in the subscript code,

the behaviour being partial matching?

> 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.

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.


> 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
>
> ______________________________________________
> 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
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list