edgeset.constructors {network} | R Documentation |
These functions convert relational data in matrix form to network edge sets.
network.adjacency(x, g, ignore.eval = TRUE, names.eval = NULL, ...) network.edgelist(x, g, ignore.eval = TRUE, names.eval = NULL, ...) network.incidence(x, g, ignore.eval = TRUE, names.eval = NULL, ...) network.bipartite(x, g, ignore.eval = TRUE, names.eval = NULL, ...)
x |
a matrix containing edge information |
g |
an object of class network |
ignore.eval |
logical; ignore edge values? |
names.eval |
the edge attribute under which to store edge values, if any |
... |
additional arguments to add.edge |
Each of the above functions takes a network
and a matrix as input, and modifies the supplied network
object by adding the appropriate edges. network.adjacency
takes x
to be an adjacency matrix; code.edgelist
takes x
to be an edgelist matrix; and network.incidence
takes x
to be an incidence matrix. network.bipartite
takes x
to be a two-mode adjacency matrix where rows and columns reflect each respective mode (conventionally, actors and events); If ignore.eval==FALSE
, (non-zero) edge values are stored as edgewise attributes with name names.eval
. Any additional command line parameters are passed to add.edge
.
Results similar to network.adjacency can also be obtained by means of extraction/replacement operators. See the associated man page for details.
Invisibly, an object of class network
; these functions modify their argument in place.
Handling of missing data is not yet fully implemented.
Carter T. Butts buttsc@uci.edu and David Hunter dhunter@stat.psu.edu
Butts, C. T. (2008). “network: a Package for Managing Relational Data in R.” Journal of Statistical Software, 24(2). http://www.jstatsoft.org/v24/i02/
network
, network.initialize
, add.edge
, network.extraction
#Create an arbitrary adjacency matrix m<-matrix(rbinom(25,1,0.5),5,5) diag(m)<-0 g<-network.initialize(5) #Initialize the network network.adjacency(m,g) #Import the edge data #Do the same thing, using replacement operators g<-network.initialize(5) g[,]<-m