toTable(x)
turns Bimap object x
into a
data frame (see section "Flat representation of a bimap" in
?Bimap
for a short introduction to this concept).
For simple maps (i.e. no tags and no right attributes),
the resulting data frame has only 2 columns, one for the left
keys and one for the right keys, and each row in the data frame
represents a link (or edge) between a left and a right key.
For maps with tagged links (i.e. a tag is associated to each
link), toTable(x)
has one additional colmun for the tags
and there is still one row per link.
For maps with right attributes (i.e. a set of attributes is
associated to each right key), toTable(x)
has one
additional colmun per attribute. So for example if x
has
tagged links and 2 right attributes, toTable(x)
will
have 5 columns: one for the left keys, one for the right keys,
one for the tags, and one for each right attribute (always the
rightmost columns).
Note that if at least one of the right attributes is multivalued
then more than 1 row can be needed to represent the same link
so the number of rows in toTable(x)
can be strictly
greater than the number of links in the map. nrow(x)
is equivalent to (but more efficient than)
nrow(toTable(x))
.
ncol(x)
is equivalent to (but more efficient than)
ncol(toTable(x))
.
colnames(x)
is equivalent to (but more efficient than)
colnames(toTable(x))
. Columns are named accordingly to
the names of the SQL columns where the data are coming from.
An important consequence of this that they are not necessarily
unique.
colmetanames(x)
returns the metanames for the column of
x
that are not right attributes. Valid column metanames
are "Lkeyname"
, "Rkeyname"
and "tagname"
.
Lkeyname
, Rkeyname
, tagname
and
Rattribnames
return the name of the column (or columns)
containing the left keys, the right keys, the tags and the right
attributes, respectively.
Like toTable(x)
, links(x)
turns x
into a
data frame but the right attributes (if any) are dropped.
Note that dropping the right attributes produces a data frame
that has eventually less columns than toTable(x)
and also eventually less rows because now exactly 1 row is
needed to represent 1 link.
count.links(x)
is equivalent to (but more efficient than)
nrow(links(x))
.
nhit(x)
returns a named integer vector indicating the
number of "hits" for each key in x
i.e. the number of links
that start from each key.