View source: R/network-utils.R
| select_top | R Documentation |
Select the top N nodes ranked by a centrality measure.
select_top(
x,
n,
by = "degree",
...,
.keep_edges = c("internal", "none"),
keep_format = FALSE,
directed = NULL
)
x |
Network input. |
n |
Integer. Number of top nodes to select. |
by |
Character. Centrality measure for ranking. One of:
|
... |
Additional filter expressions to apply. |
.keep_edges |
How to handle edges. Default "internal". |
keep_format |
Logical. Keep input format? Default FALSE. |
directed |
Logical or NULL. Auto-detect if NULL. |
A cograph_network with the top N nodes.
select_nodes, select_component
adj <- matrix(c(0, .5, .8, 0,
.5, 0, .3, .6,
.8, .3, 0, .4,
0, .6, .4, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")
# Top 2 by degree
select_top(adj, n = 2)
# Top 2 by PageRank
select_top(adj, n = 2, by = "pagerank")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.