as.matrix.network {network}R Documentation

Coerce a Network Object to Matrix Form

Description

The as.matrix methods attempt to coerce their input to a matrix in adjacency, incidence, or edgelist form. Edge values (from a stored attribute) may be used if present.

Usage

as.matrix.network(x, matrix.type = NULL, attrname = NULL)
as.matrix.network.adjacency(x,attrname=NULL)
as.matrix.network.edgelist(x,attrname=NULL)
as.matrix.network.incidence(x,attrname=NULL)

Arguments

x an object of class network
matrix.type one of "adjacency", "incidence", "edgelist", or NULL
attrname optionally, the name of an edge attribute to use for edge values

Details

If no matrix type is specified, which.matrix.type will be used to make an educated guess based on the shape of x. Where edge values are not specified, a dichotomous matrix will be assumed.

Value

An adjacency, incidence, or edgelist matrix

Author(s)

Carter T. Butts buttsc@uci.edu and David Hunter dhunter@stat.psu.edu

References

Butts, C.T. 2002. ``Memory Structures for Relational Data in R: Classes and Interfaces'' Working Paper.

See Also

which.matrix.type, network

Examples

#Create a random network
m <- matrix(rbinom(25,1,0.5),5,5)
diag(m) <- 0
g <- network(m)

#Coerce to matrix form
as.matrix.network(g,matrix.type="adjacency")
as.matrix.network(g,matrix.type="incidence")
as.matrix.network(g,matrix.type="edgelist")

[Package network version 0.5-4 Index]