Learn R Programming

cograph (version 2.0.0)

as_mcml: Convert to mcml

Description

Convert various objects to the mcml class -- a clean, tna-independent representation of a multilayer cluster network.

Usage

as_mcml(x, ...)

# S3 method for cluster_summary as_mcml(x, ...)

# S3 method for group_tna as_mcml(x, clusters = NULL, method = "sum", type = "tna", directed = TRUE, ...)

# S3 method for mcml as_mcml(x, ...)

# S3 method for default as_mcml(x, ...)

Value

An mcml object with components macro, clusters, cluster_members, and meta.

An mcml object.

An mcml object. When clusters is provided, macro$data contains the cluster assignments and macro$weights

is NULL (the macro is the sequence of clusters, not a summary).

The input mcml object unchanged.

Arguments

x

Object to convert.

...

Additional arguments passed to methods.

clusters

Integer or character vector of row-to-group assignments. Required when the group_tna has the same labels across all groups (row-level clustering from tna::group_model(cluster_data(...))).

method

Aggregation method for macro weights (default "sum").

type

Transition type (default "tna").

directed

Logical; whether the network is directed (default TRUE).

See Also

build_mcml, as_tna

Examples

Run this code
# From cluster_summary
mat <- matrix(c(0.5, 0.2, 0.3,
                0.1, 0.6, 0.3,
                0.4, 0.1, 0.5), 3, 3, byrow = TRUE,
              dimnames = list(c("A", "B", "C"), c("A", "B", "C")))
clusters <- list(G1 = c("A", "B"), G2 = c("C"))
cs <- cluster_summary(mat, clusters, type = "tna")
m <- as_mcml(cs)
m$macro$weights

if (FALSE) {
# From group_tna with cluster assignments (requires tna + Nestimate)
seqs <- data.frame(T1 = c("A", "B", "A"), T2 = c("B", "A", "B"))
mod <- tna::tna(seqs)
cl <- Nestimate::cluster_data(mod, k = 2)
gt <- tna::group_model(cl)
m <- as_mcml(gt, clusters = cl$assignments)
}

Run the code above in your browser using DataLab