invert: Create/invert a hash.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

THIS IS AN EXPERIMENTAL FUNCTION. THE IMPLEMENTATION OR INTERFACE MAY CHANGE IN THE FUTURE.

Usage

1
2
3
4
5
6
invert(x)

## S4 method for signature 'hash'
invert(x)

inverted.hash(...)

Arguments

x

A hash() object

...

Arguments passed to the hash() function.

Details

invert exchanges the keys and values of a hash.

inverted.hash is a constructor method that directly makes an inverted hash.

Each element of the values(x) becomes a key in a new hash; the associatedis coerced to a key value is the The value becomes the associated key.

For inverted.hash, a hash is created thnn 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

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

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

decisionpatterns/r-hash documentation built on Feb. 6, 2019, 10:27 p.m.