merge_weights: Put the weights of several measures side by side, with their...

View source: R/compare_weights.R

merge_weightsR Documentation

Put the weights of several measures side by side, with their ranks

Description

Joins a named list of edge tables (for instance the result of compute_couplings()) by pair of nodes, with one column of weights per element, and, by default, the rank of each pair under each measure and the gap between the ranks of two measures. It is the table behind the other comparison functions, and the tool to inspect the pairs on which two measures disagree.

Usage

merge_weights(
  edges,
  rank = TRUE,
  rank_gap = NULL,
  ties = c("average", "min", "max", "first")
)

Arguments

edges

A named list of edge tables, each with the columns Source, Target and weight. The tables are not modified.

rank

Logical. If TRUE (default), adds one ⁠rank_<name>⁠ column per element of edges.

rank_gap

Character vector of two names of edges, or NULL (default). If given, adds the rank_gap column, ⁠rank_<second> - rank_<first>⁠. If NULL and edges has exactly two elements, the gap between them (second minus first) is computed. It requires rank = TRUE.

ties

How ties are ranked, as in data.table::frank() ("average" by default).

Details

[Experimental]

Weights of different measures do not have the same scale, but their ranks do: rank 1 is the strongest pair of the measure. A pair with a high weight for one measure and a low weight for another has a large gap between the two ranks. The gap is

\mathrm{rank\_gap}_{AB} = \mathrm{rank}_{2}(A, B) - \mathrm{rank}_{1}(A, B)

with 1 and 2 the first and second elements of rank_gap: it is positive when the second measure ranks the pair lower (as less close) than the first one, negative when it ranks it higher. Sorting the table on the gap (decreasing, then increasing) gives the pairs on which the measures disagree the most.

Ranks are computed on the pairs present in all the tables, so that they are comparable: the pairs that a measure does not have (for instance those of coupling_descriptive(), which links documents that share no reference) get NA ranks.

Value

A data.table with Source, Target, one column of weights per element of edges and, according to the arguments, the ⁠rank_<name>⁠ columns and rank_gap. A pair absent from a table (for instance because tables were built with different thresholds) gets NA.

See Also

Other tools to compare coupling measures: compute_couplings(), correlate_weights(), overlap_top_weights(), plot_weights(), summarise_weights()

Examples

library(biblionetwork)
edges <- compute_couplings(Ref_stagflation, "Citing_ItemID_Ref", "ItemID_Ref",
                           methods = c("angle", "strength"), weight_threshold = 2)
merged <- merge_weights(edges)
head(merged)

# The pairs that the angle ranks high and the strength ranks low
head(merged[order(-rank_gap)])


biblionetwork documentation built on Nov. 4, 2026, 5:07 p.m.