pagerank_grid: Run PageRank Across Multiple Parameter Sets

View source: R/pagerank_grid.R

pagerank_gridR Documentation

Run PageRank Across Multiple Parameter Sets

Description

Executes [pagerank()] for each entry in a named parameter grid, returning a single combined data frame with a 'model_id' column identifying which configuration produced each row.

Usage

pagerank_grid(
  edge_list_df,
  params_grid,
  redirects_df = NULL,
  ...,
  edge_from_col = "from",
  edge_to_col = "to"
)

Arguments

edge_list_df

A data frame representing the edge list (passed to every [pagerank()] call).

params_grid

A named list of named lists. Each inner list contains parameter overrides for [pagerank()]. The top-level names become the 'model_id' values in the output.

redirects_df

An optional redirect data frame (passed to every call). Default 'NULL'.

...

Common parameters shared across all models (e.g., 'clean_edge_urls', 'rurl_params', 'damping'). These are passed to every [pagerank()] call and can be overridden by entries in 'params_grid'.

edge_from_col, edge_to_col

Names of from/to columns in 'edge_list_df'. Default '"from"' / '"to"'.

Value

A data frame with columns 'model_id', 'node_name', and 'pagerank' (or the column names returned by [pagerank()]). Rows from different models are stacked via [rbind()].

Examples

edges <- data.frame(
  from = c("A", "B", "C", "A"),
  to = c("B", "C", "A", "C")
)
params <- list(
  baseline = list(damping = 0.85, self_loops = "drop"),
  high_damp = list(damping = 0.95, self_loops = "drop"),
  keep_loops = list(damping = 0.85, self_loops = "keep")
)
grid <- pagerank_grid(edges, params, clean_edge_urls = FALSE)
print(grid)

# Compare two models from the grid
baseline <- grid[grid$model_id == "baseline", ]
high_damp <- grid[grid$model_id == "high_damp", ]
compare_pagerank(baseline, high_damp)

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