Learn R Programming

cograph (version 2.7.2)

aggregate_layers: Aggregate Layers

Description

Combines multiple network layers into a single network.

Usage

aggregate_layers(
  layers,
  method = c("sum", "mean", "max", "min", "union", "intersection"),
  weights = NULL
)

lagg( layers, method = c("sum", "mean", "max", "min", "union", "intersection"), weights = NULL )

Value

Aggregated adjacency matrix

Arguments

layers

List of adjacency matrices

method

Aggregation: "sum", "mean", "max", "min", "union", "intersection"

weights

Optional layer weights (for weighted sum)

Examples

Run this code
nodes <- c("A", "B", "C")
l1 <- matrix(c(0, 1, 0, 1, 0, 1, 0, 1, 0), 3, 3, dimnames = list(nodes, nodes))
l2 <- matrix(c(0, 1, 1, 1, 0, 0, 1, 0, 0), 3, 3, dimnames = list(nodes, nodes))
layers <- list(L1 = l1, L2 = l2)

aggregate_layers(layers, "sum")           # total edge weight
aggregate_layers(layers, "mean")          # average edge weight
aggregate_layers(layers, "union")         # edge present in any layer
aggregate_layers(layers, "intersection")  # edge present in every layer

Run the code above in your browser using DataLab