View source: R/class-network.R
| set_groups | R Documentation |
Assigns node groupings to a cograph_network object. Groups are stored as metadata with a type column ("layer", "cluster", or "group") for use by specialized plot functions.
set_groups(
x,
groups = NULL,
type = c("group", "cluster", "layer"),
nodes = NULL,
layers = NULL,
clusters = NULL
)
x |
A cograph_network object. |
groups |
Node groupings in one of these formats:
|
type |
Group type. One of |
nodes |
Character vector of node labels. Use with |
layers |
Character/factor vector of layer assignments (same length as |
clusters |
Character/factor vector of cluster assignments (same length as |
The modified cograph_network object with node_groups set.
get_groups, splot, detect_communities
set.seed(1)
mat <- matrix(runif(100), 10, 10)
mat <- (mat + t(mat)) / 2; diag(mat) <- 0
rownames(mat) <- colnames(mat) <- paste0("N", 1:10)
net <- as_cograph(mat)
# Named list -> layers
net <- set_groups(net, list(
Macro = paste0("N", 1:3),
Meso = paste0("N", 4:7),
Micro = paste0("N", 8:10)
), type = "layer")
get_groups(net)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.