Learn R Programming

network (version 1.19.0)

mixingmatrix: Mixing matrix

Description

Return the mixing matrix for a network, on a given attribute.

Usage

mixingmatrix(object, ...)

# S3 method for network mixingmatrix(object, attrname, useNA = "ifany", expand.bipartite = FALSE, ...)

# S3 method for mixingmatrix [[(x, ...)

# S3 method for mixingmatrix $(x, name)

# S3 method for mixingmatrix is.directed(x, ...)

# S3 method for mixingmatrix is.bipartite(x, ...)

# S3 method for mixingmatrix print(x, ...)

Value

Function mixingmatrix() returns an object of class mixingmatrix

extending table with a cross-tabulation of edges in the object

according to the values of attribute attrname for the two incident vertices. If object is a directed network rows correspond to the "tie sender" and columns to the "tie receiver". If object is an undirected

network there is no such distinction and the matrix is symmetrized. In both cases the matrix is square and all the observed values of the attribute attrname are represented in rows and columns. If object is a bipartite network and expand.bipartite is FALSE the resulting matrix does not have to be square as only the actually observed values of the attribute are shown for each partition, if expand.bipartite is TRUE the matrix will be square.

Functions is.directed() and is.bipartite() return TRUE or FALSE. The values will be identical for the input network object.

Arguments

object

a network or some other data structure for which a mixing matrix is meaningful.

...

arguments passed to table.

attrname

a vertex attribute name.

useNA

one of "ifany", "no" or "always". Argument passed to table. By default (useNA = "ifany") if there are any NAs on the attribute corresponding row and column will be contained in the result. See Details.

expand.bipartite

logical; if object is bipartite, should we return the square mixing matrix representing every level of attrname against every other level, or a rectangular matrix considering only levels present in each bipartition?

x

mixingmatrix object

name

name of the element to extract, one of "matrix" or "type"

Details

Handling of missing values on the attribute attrname almost follows similar logic to table. If there are NAs on the attribute and useNA="ifany" (default) the result will contain both row and column for the missing values to ensure the resulting matrix is square (essentially calling table with useNA="always"). Also for that reason passing exclude parameter with NULL, NA or NaN is ignored with a warning as it may break the symmetry.

Examples

Run this code
# Interaction ties between Lake Pomona SAR organizations by sponsorship type
# of tie sender and receiver (data from Drabek et al. 1981)
data(emon)
mixingmatrix(emon$LakePomona, "Sponsorship")

Run the code above in your browser using DataLab