compare_pagerank: Compare Two PageRank Results

View source: R/compare_pagerank.R

compare_pagerankR Documentation

Compare Two PageRank Results

Description

Performs a full outer join on two PageRank result data frames and computes deltas, percentage changes, and rank changes for each node. Summary statistics are attached as an attribute.

Usage

compare_pagerank(
  pr_a,
  pr_b,
  node_col = "node_name",
  pr_col = "pagerank",
  label_a = "a",
  label_b = "b"
)

Arguments

pr_a

A data frame of PageRank results (model A / baseline).

pr_b

A data frame of PageRank results (model B / comparison).

node_col

Name of the node column present in both data frames. Default '"node_name"'.

pr_col

Name of the PageRank value column present in both data frames. Default '"pagerank"'.

label_a

Short label for model A (used in output column names). Default '"a"'.

label_b

Short label for model B (used in output column names). Default '"b"'.

Value

A data frame with columns:

node_name

Node identifier

pagerank_a, pagerank_b

PageRank scores from each model ('NA' when the node is absent from that model)

delta

'pagerank_b - pagerank_a'

pct_change

Percentage change from a to b ('NA' when a is 'NA' or 0)

rank_a, rank_b

Ordinal rank (1 = highest PageRank) within each model ('NA' when the node is absent)

rank_delta

'rank_a - rank_b' (positive = improved in b)

A '"summary"' attribute (named list) is attached with:

spearman_rho

Spearman rank correlation on common nodes

mean_abs_delta

Mean of absolute delta on common nodes

nodes_gained

Count of nodes in b but not a

nodes_lost

Count of nodes in a but not b

Examples

pr_a <- data.frame(
  node_name = c("A", "B", "C"),
  pagerank = c(0.5, 0.3, 0.2)
)
pr_b <- data.frame(
  node_name = c("A", "B", "D"),
  pagerank = c(0.4, 0.35, 0.25)
)
result <- compare_pagerank(pr_a, pr_b)
print(result)
attr(result, "summary")

pagerankr documentation built on Oct. 1, 2026, 5:09 p.m.