as.symmetricAdjacencyMatrix {DCG}R Documentation

convert to a symmetric adjacency matrix

Description

as.symmetricAdjacencyMatrix convert an edgelist or a raw matrix to a symmetric adjacency matrix.

Usage

as.symmetricAdjacencyMatrix(Data, weighted = FALSE, rule = "weak")

Arguments

Data

either a dataframe or a matrix, representing raw interactions using either an edgelist or a matrix. Frequency of interactions for each dyad can be represented either by multiple occurrences of the dyad for a 2-column edgelist, or by a third column specifying the frequency of the interaction for a 3-column edgelist.

weighted

If the edgelist is a 3-column edgelist in which weight was specified by frequency, use weighted = TRUE.

rule

a character vector of length 1, being one of "weak", "strong", "upper", or "lower". Ways of symmetrizing the matrix. See details for more information.

Details

There are ways of symmetrizing a matrix. The "weak" rule symmetrize the matrix by building an edge between nodes [i, j] and [j, i] if there is an edge either from i to j OR from j to i. The "strong" rule symmetrize the matrix by building an edge between nodes [i, j] and [j, i] if there is an edge BOTH from i to j AND from j to i. The "upper" and the "lower" rule symmetrize the matrix by using the "upper" or the "lower" triangle respectively.

Note, when using a 3-column edgelist (e.g. a weighted edgelist) to represent raw interactions, each dyad must be unique. If more than one rows are found with the same Initiator and recipient, sum of the frequencies will be taken to represent the freqency of interactions between this unique dyad. A warning message will prompt your attention to the accuracy of your raw data when duplicated dyads were found in a three-column edgelist.

Value

a named matrix with the [i,j]th entry equal to the number of times i grooms j.

Examples

symmetricMatrix <- as.symmetricAdjacencyMatrix(monkeyGrooming, weighted = TRUE, rule = "weak")


[Package DCG version 0.9.3 Index]