Learn R Programming

qdap (version 1.3.5)

hash: Hash/Dictionary Lookup

Description

hash - Creates a new environment for quick hash style dictionary lookup. hash_look - Works with a hash table such as is returned from hash, to lookup values. %ha% - A binary operator version of hash_look.

Usage

hash(x, mode.out = "numeric")

hash_look(terms, envir, missing = NA)

terms %ha% envir

Arguments

x
A two column dataframe.
mode.out
The type of output (column 2) expected (e.g., "character", "numeric", etc.)
terms
A vector of terms to undergo a lookup.
envir
The hash environment to use.
missing
Value to assign to terms not found in the hash table.

Value

  • Creates a "hash table", a two column data frame in its own environment.

References

http://www.talkstats.com/showthread.php/22754-Create-a-fast-dictionary

See Also

lookup, environment

Examples

Run this code
(DF <- aggregate(mpg~as.character(carb), mtcars, mean))
new.hash1 <- hash(DF)  #numeric outcome
x <- sample(DF[, 1], 20, TRUE)
hash_look(x, new.hash1)

new.hash2 <- hash(DF, "character") #character outcome
x %ha% new.hash2

Run the code above in your browser using DataLab