Resolve edge endpoints through rel=canonical declarations
Source:R/resolve_canonicals.R
resolve_canonicals.RdApplies declared `rel=canonical` folds to the source and target columns of an edge list. This is URL **folding** from canonical-link signals, not URL syntax canonicalization such as lower-casing hosts or removing tracking parameters.
Usage
resolve_canonicals(
edge_list_df,
canonicals_df,
edge_from_col = "from",
edge_to_col = "to",
canonical_from_col = "from",
canonical_to_col = "to",
canonical_duplicate_from_policy = c("strict", "first_wins", "last_wins",
"most_frequent", "prune_source", "resolve_if_consistent"),
canonical_loop_handling = c("error", "prune_loop", "break_arrow")
)Arguments
- edge_list_df
A data frame representing the edge list.
- canonicals_df
A data frame of declared canonical links.
- edge_from_col, edge_to_col
Source/target columns in `edge_list_df`.
- canonical_from_col, canonical_to_col
From/to columns in `canonicals_df`.
- canonical_duplicate_from_policy
How to handle a canonical source with multiple distinct targets. See [build_fold_map()].
- canonical_loop_handling
How to handle canonical cycles. See [build_fold_map()].
Value
The edge list with `edge_from_col` and `edge_to_col` folded through canonical declarations. The applied fold map is attached as attribute `"fold_map"`.
Examples
edges <- data.frame(from = "A", to = "B")
canonicals <- data.frame(from = "B", to = "C")
resolve_canonicals(edges, canonicals)
#> from to
#> 1 A C