invert {hash}R Documentation

Create an inverted hash.

Description

Invert creates an inverted hash from an existing hash. An inverted hash is one in which the keys and values are exchanged.

Usage

invert(x)
inverted.hash(...)

Arguments

x A hash object
... Arguments passed to hash

Details

For invert, keys and value elements swtich. Each element of the values(x) is coerced to a key. The value is the associated key.

For inverted.hash, a hash is created than inverted. It is defined as:

function(...) invert(hash(...))

Value

A hash object with: keys as the unique elements of values(x) and values as the associated keys{x}

Author(s)

Christopher Brown

See Also

See also link{hash} and make.keys

Examples

  h <- hash( a=1, b=1:2, c=1:3 )
  invert(h)

  inverted.hash( a=1, b=1:2, c=1:3 )


[Package hash version 1.0.2 Index]