invert.RdTHIS IS AN EXPERIMENTAL FUNCTION. THE IMPLEMENTATION OR INTERFACE MAY CHANGE WITHOUT WARNING.
Invert creates an inverted hash from an existing hash. An inverted hash is one in which the keys and values are exchanged.
invert(x)
inverted.hash(...)For invert, keys and value elements switch. Each element of the
values(x) is coerced to a key. The value becomes the associated key.
For inverted.hash, a hash is created than inverted. It is defined as:
function(...) invert(hash(...))
A hash object with:
keys as the unique elements of values(x) and
values as the associated keys{x}
See also link{hash} and make.keys
h <- hash( a=1, b=1:2, c=1:3 )
invert(h)
#> <hash> containing 3 key-value pair(s).
#> 1 : a b c
#> 2 : b c
#> 3 : c
inverted.hash( a=1, b=1:2, c=1:3 )
#> <hash> containing 3 key-value pair(s).
#> 1 : a b c
#> 2 : b c
#> 3 : c