Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

which.matrix.type

Heuristic Determination of Matrix Types for Network Storage


Description

which.matrix.type attempts to choose an appropriate matrix expression for a network object, or (if its argument is a matrix) attempts to determine whether the matrix is of type adjacency, incidence, or edgelist.

Usage

which.matrix.type(x)

Arguments

x

a matrix, or an object of class network

Details

The heuristics used to determine matrix types are fairly arbitrary, and should be avoided where possible. This function is intended to provide a modestly intelligent fallback option when explicit identification by the user is not possible.

Value

One of "adjacency", "incidence", or "edgelist"

Author(s)

David Hunter dhunter@stat.psu.edu

References

Butts, C. T. (2008). “network: a Package for Managing Relational Data in R.” Journal of Statistical Software, 24(2). https://www.jstatsoft.org/v24/i02/

See Also

Examples

#Create an arbitrary adjacency matrix
  m<-matrix(rbinom(25,1,0.5),5,5)
  diag(m)<-0

  #Can we guess the type?
  which.matrix.type(m)

  #Try the same thing with a network
  g<-network(m)
  which.matrix.type(g)
  which.matrix.type(as.matrix.network(g,matrix.type="incidence"))
  which.matrix.type(as.matrix.network(g,matrix.type="edgelist"))

network

Classes for Relational Data

v1.16.1
GPL (>= 2)
Authors
Carter T. Butts [aut, cre], David Hunter [ctb], Mark Handcock [ctb], Skye Bender-deMoll [ctb], Jeffrey Horner [ctb], Li Wang [ctb]
Initial release
2020-10-06

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.