This package implements a data structure similar to hashes in Perl and dictionaries in Python but with a purposefully R flavor. For objects of appreciable size, access using hashes outperforms native named lists and vectors.
The hash package provides a fully-functional hash / dictionary functionality for the R language (http://decisionpatters.com).
HASH KEYS must be a valid character value and may not be the empty string \code{""}.
HASH VALUES can be any R value, vector or object.
The hash package is the only full featured hash implementation for the R language. It provides more features and finer control of the hash behavior than the native feature set and has similar and sometimes better performance.
PASS-BY REFERENCE. Environments and hashes are special objects in R because only one copy exists globally. When provide as an argument to a function, no local copy is made and any changes to the hash in the functions are reflected globally.
PERFORMANCE. Hashes are based on R's native environments and are designed to be exceedingly fast using the environments internal hash table. For small data structures, a list will out-perform a hash in nearly every case. For larger data structure, i.e. > 500 key value pair the performance of the hash becomes faster. Much beyond that the performance of the hash far outperforms native lists.
MEMORY. Objects of class hash do not release memory with a call to rm. clear must be called before rm to properly release the memory.
h[]
returns a copy of hNew ways to edit key names:
** setkeys
allows setting of key names similar to data.table's setnames
** keys<-
for setting simple keys
names
works same as keys
2013-02-20 Version 2.2.6
2013-01-31 Version 2.2.5 Fixes bug with has.key. Because of the default settingg of inherits=TRUE in the exists function, the has.key function was revealing keys for objects found on inherited environments, this included functions such as 'c' and 'q'. Thanks to Michael Pratt for spotting the bug.
2012-04-25 Version 2.2.0 Recaptured orphaned package
2011-03-17 Version 2.1.0 Changed contact information.
2010-09-26 Version 2.0.2 (cbrown) Just releasing as version 2.0.2. Mostly, documentation and benchmarks added. Unreleased to CRAN.
2010-07-25
2010-06-14
2010-05-26 Version 2.0.1 (cbrown)
Hi Christopher,
thank you for providing the package hash. I am thinking of using it in my rEMM package. Is there a way to make the load message a little less flashy. I include hash in my DESCRIPTION file and the ASCII art comes always up when my package loads.
Thanks, Michael
-- Dr. Michael Hahsler, Visiting Assistant Professor Department of Computer Science and Engineering Lyle School of Engineering Southern Methodist University, Dallas, Texas
2010-04-24 Version 2.0.0 (cbrown)
The coercion of keys make.keys has largely been deprecated. This might change in future version, but what we really want is to have any object stand for the keys that will get automatically converted. This might be make.key in the future. Also, we removed .get. All the accessor coding now exists in the definition of the native accessors.
R/format : implement max.print to display only getOption('max.print') keys.
R/na.actions : na..hash function's have been renamed to hash.na.function. This is so as not to conflict with the base::na. S3 functions. It is unfortunate, because it would have been nice to retain a name. It was impossible because of the generic form of the functions, na.fail which requires an object as the first argument. Meanwhile, the 'ifnotfound' argument of mget takes one argument. mget is extensively used in this package and the one argument that needs to be passed is the name of the key. The choice was to either re-write the standardGeneric which will cause downstream problems -OR- abandone the na.* names. The latter was chosen with the added benefit that other hash controlled options would be grouped by hash.* in the option vector.
R/Class-hash:
R/hash-benchmark.R
DESCRIPTION:
R/get-R: .get DEPRECATED for perfomance reasons.
R/values.R:
R/hash-action.R : DEPRECATED After renaming these, it was decided that these would be DEPRECATED. Sometimes consitency is better than customizabilty. replaces R/na.action with the following funcitons renamed:
2010-03-15
Some R data types do not behave normally, in the sense that they are non-local references or other objects that are not duplicated. Examples include those corresponding to classes "environment", "externalptr", and "name". These can not be the types for objects with user-defined classes (either S4 or S3) because setting an attribute overwrites the object in all contexts. It is possible to define a class that inherits from such types, through an indirect mechanism that stores the inherited object in a reserved slot. The implementation tries to make such classes behave as if the object had a data part of the corresponding object type. Methods defined with the object type in the signature should work as should core code that coerces an object to the type in an internal or primitive calculation. There is no guarantee, however, because C-level code may switch directly on the object type, which in this case will be "S4". The cautious mechanism is to use as(x, "environment") or something similar before doing the low-level computation. See the example for class "stampedEnv" below.
2010-02-16 Version 1.99.3 (cbrown)
2010-02-16 Version 1.99.1 (cbrown)
2010-02-16 Version 1.99.0 (cbrown) RELEASE CANDIDATE FOR VERSION 2.00 THIS VERSION BREAKS BACKWARD COMPATABILITY WHEN TRYING TO ACCESS A NON-EXISTANT KEY. PACKAGE NOW RETURNS NA BY DEFAULT, BUT BAHAVIOUR IS CONTROLABLE BY Options('na.default.hash')
2010-02-15 Version 1.10.3 (cbrown)
2010-01-01 Version 1.10.2 (cbrown)
2009-12-09 Version 1.10.1 (cbrown)
2009-11-29 Version 1.10.0 (cbrown)
2009-11-11 (cbrown)
2009-11-04 Version 1.0.3 (cbrown)
2009-10-14 (cbrown)
2009-10-11 (cbrown) Version 1.0.2
2009-10-09 (cbrown) Version 1.0.1 ( not released on CRAN )
2009-09-30 (cbrown)
2009-09-28 (cbrown)
R/hash.R:
R/show.R: Now aliases format
R/format.R: added
R/zzz.R: added graphical Open Data Logo
R/print.R: added
2009-09-04 (cbrown)
2009-09-04 Version 0.40 (cbrown)