View source: R/resolve_links.R
| resolve_links | R Documentation |
Applies redirect rules to an edge list and returns the resolved link graph without computing PageRank. Useful for inspecting what the link graph looks like after redirects are applied, deduplication, and optional URL cleaning.
resolve_links(
edge_list_df,
redirects_df = NULL,
clean_urls = TRUE,
self_loops = c("drop", "keep"),
edge_from_col = "from",
edge_to_col = "to",
redirect_from_col = "from",
redirect_to_col = "to",
duplicate_from_policy = c("strict", "first_wins", "last_wins", "most_frequent",
"prune_source", "resolve_if_consistent"),
loop_handling = c("error", "prune_loop", "break_arrow"),
rurl_params = list()
)
edge_list_df |
A data frame representing the edge list with at least two columns for source and target URLs. |
redirects_df |
A data frame containing redirect rules with 'from' and 'to' columns (or as specified by 'redirect_from_col'/'redirect_to_col'). If 'NULL', no redirects are applied. |
clean_urls |
Logical, whether to clean/normalize URLs using
|
self_loops |
Character, how to handle self-loops created after redirect resolution. One of '"drop"' (default) or '"keep"'. |
edge_from_col, edge_to_col |
Names of the from/to columns in 'edge_list_df'. Default '"from"' and '"to"'. |
redirect_from_col, redirect_to_col |
Names of the from/to columns in 'redirects_df'. Default '"from"' and '"to"'. |
duplicate_from_policy |
How to handle conflicting redirects. Passed through to [resolve_redirects()]. Default '"strict"'. |
loop_handling |
How to handle redirect cycles. Passed through to [resolve_redirects()]. Default '"error"'. |
rurl_params |
Named list of additional arguments passed to
|
A data frame with the same columns as 'edge_list_df', but with URLs replaced by their final redirect destinations, duplicate edges removed, and self-loops handled according to 'self_loops'.
Other edge-list resolvers:
resolve_canonicals(),
resolve_redirects()
edges <- data.frame(
from = c("A", "B", "C", "A"),
to = c("B", "C", "D", "B")
)
redirects <- data.frame(
from = c("B", "C"),
to = c("B_final", "C_final")
)
resolve_links(edges, redirects, clean_urls = FALSE)
# Without redirects: just deduplicate and clean
resolve_links(edges, clean_urls = FALSE)
# Inspect the graph before and after a redirect change
before <- resolve_links(edges, clean_urls = FALSE)
new_redirects <- data.frame(
from = "D", to = "B_final"
)
after <- resolve_links(edges, new_redirects, clean_urls = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.