| prune | R Documentation |
Reduces a weighted edge list by removing weak or excess edges.
prune(edges, threshold = NULL, top_n = NULL)
edges |
A data frame with at least columns |
threshold |
Numeric. Keep only edges with |
top_n |
Integer. For each node, keep only its |
The filtered edge data frame (same columns as input).
edges <- data.frame(
from = c("A","A","A","B","B","C"),
to = c("B","C","D","C","D","D"),
weight = c(5, 1, 2, 4, 1, 3)
)
# Keep only edges with weight >= 3
prune(edges, threshold = 3)
# Keep the 2 strongest edges per node
prune(edges, top_n = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.