[R] hash argument of new.env()

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Oct 8 13:55:40 CEST 2002


Jonathan Rougier <J.C.Rougier at durham.ac.uk> writes:

> Hi everyone,
> 
> There is no mention in ?new.env (R-1.6.0) of what the effect of setting
> the hash argument of new.env() actually does.  What does it mean in
> performance terms to say that "the environment will be hashed"?

It's difficult to say since there are various tradeoffs (especially
between speed and space). Empirically, I seem to recall that we did
some benchmarking and the effect of hashing was essentially nil for
typical environments created by R function calls. However, that's not
the only potential usage of environments in R; they can also be used
for what other languages call associative arrays or hashes. For large
environments, the potential speedup is from the O(N) complexity of a
linear search to a constant-time lookup using a hash-key on a near
empty table, but there's also an administrative overhead of re-hashing
an environment if it outgrows its hashtable, etc., etc.

There are several webpages that discuss hashing (although not all of
them relate to this particular meaning of the word...) e.g.
http://www-theory.dcs.st-and.ac.uk/~mda/cs2001/hashing/general.html

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list