All Bimap objects have a direction which can be left-to-right
(i.e. the mapping goes from the left keys to the right keys)
or right-to-left (i.e. the mapping goes from the right keys to the
left keys).
A Bimap object x
that maps from left to right is
considered to be a direct map. Otherwise it is considered to be an
indirect map (when it maps from right to left). direction
returns 1
on a direct map and -1
otherwise.
The direction of x
can be changed with direction(x) <- value
where value must be 1
or -1
.
An easy way to reverse a map (i.e. to change its direction) is to
do direction(x) <- - direction(x)
, or, even better, to use
revmap(x)
which is actually the recommended way for doing it.
The Lkeys
and Rkeys
methods return respectively
the left and right keys of a Bimap object.
Unlike the keys
method (see ?keys
for
more information), these methods are direction-independent i.e. what
they return does NOT depend on the direction of the map.
Such methods are also said to be "undirected methods"
and methods like the keys
method are said
to be "directed methods".
All the methods described below are also "undirected methods".
Llength(x)
and Rlength(x)
are equivalent to
(but more efficient than) length(Lkeys(x))
and
length(Rkeys(x))
, respectively.
The mappedLkeys
(or mappedRkeys
) method returns
the left keys (or right keys) that are mapped to at least one right
key (or one left key).
count.mappedLkeys(x)
and count.mappedRkeys(x)
are
equivalent to (but more efficient than) length(mappedLkeys(x))
and length(mappedRkeys(x))
, respectively. These functions give
overall summaries, if you want to know how many Rkeys correspond to a
given Lkey you can use the nhit
function.
Lkeys(x) <- value
and Rkeys(x) <- value
are the
undirected versions of keys(x) <- value
(see ?keys
for more information) and subset(x, Lkeys=new_Lkeys, Rkeys=new_Rkeys)
is provided as a convenient way to reduce the sets of left
and right keys in one single function call.