Learn R Programming

hash (version 2.2.6.3)

hash-class: Class "hash"

Description

Implements a S4 hash class in R similar to hashes / associated arrays / dictionaries in other programming languages. Where possible, the hash class uses the standard R accessors: $, [ and [[. Hash construction is flexible and takes several syntaxes and all hash operations are supported.

For shorter key-value pairs, lists might yield higher performance, but for lists of appreciable length hash objects handly outperform native lists.

Arguments

Slots

.xData:

Object of class "environment". This is the hashed environment used for key-value storage.

Extends

environment

Methods

HASH ACCESSORS:
[<-

signature(x = "hash", i = "ANY", j = "missing"): Slice Replacement

[

signature(x = "hash", i = "ANY", j = "missing", drop = "missing") : Slice

[[<-

signature(x = "hash", i = "ANY", j = "missing"): Single key replacement with interpolation.

[[

signature(x = "hash", i = "ANY", j = "missing"): i Single key look-up with interpolation

$<-

signature(x = "hash"): Single key replacement no interpolation

$

signature(x = "hash"): Single key lookup no interpolation

Manipulation:

clear

signature(x = "hash"): Remove all key-value pairs from hash

del

signature(x = "ANY", hash = "hash"): Remove specified key-value pairs from hash

has.key

signature(key = "ANY", hash = "hash"): Test for existence of key

is.empty

signature(x = "hash"): Test if no key-values are assigned

length

signature(x = "hash"): Return number of key-value pairs from the hash

keys

signature(hash = "hash"): Retrieve keys from hash

values

signature(x = "hash"): Retrieve values from hash

copy

signature(x = "hash"): Make a copy of a hash using a new environment.

format

signature(x = "hash"): Internal function for displaying hash

Author

Christopher Brown

References

http://en.wikipedia.org/wiki/Hash_table

http://en.wikipedia.org/wiki/Associative_array

See Also

hash-accessors, environment.

Examples

Run this code
  showClass("hash")

Run the code above in your browser using DataLab