as.sociomatrix {network} | R Documentation |
Coerce One or More Networks to Sociomatrix Form
Description
as.sociomatrix
takes adjacency matrices, adjacency arrays,
network
objects, or lists thereof, and returns one or more
sociomatrices (adjacency matrices) as appropriate. This routine provides a
useful input-agnostic front-end to functions which process adjacency
matrices.
Usage
as.sociomatrix(
x,
attrname = NULL,
simplify = TRUE,
expand.bipartite = FALSE,
...
)
Arguments
x |
an adjacency matrix, array, |
attrname |
optionally, the name of a network attribute to use for
extracting edge values (if |
simplify |
logical; should |
expand.bipartite |
logical; if |
... |
additional arguments for the coercion routine. |
Details
as.sociomatrix
provides a more general means of coercing input into
adjacency matrix form than as.matrix.network
. In particular,
as.sociomatrix
will attempt to coerce all input networks into the
appropriate form, and return the resulting matrices in a regularized manner.
If simplify==TRUE
, as.sociomatrix
attempts to return the
matrices as a single adjacency array. If the input networks are of variable
size, or if simplify==FALSE
, the networks in question are returned as
a list of matrices. In any event, a single input network is always returned
as a lone matrix.
If attrname
is given, the specified edge attribute is used to extract
edge values from any network
objects contained in x
.
Note that the same attribute will be used for all networks; if no attribute
is specified, the standard dichotomous default will be used instead.
Value
One or more adjacency matrices. If all matrices are of the same
dimension and simplify==TRUE
, the matrices are joined into a single
array; otherwise, the return value is a list of single adjacency matrices.
Author(s)
Carter T. Butts buttsc@uci.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
#Generate an adjacency array
g<-array(rbinom(100,1,0.5),dim=c(4,5,5))
#Generate a network object
net<-network(matrix(rbinom(36,1,0.5),6,6))
#Coerce to adjacency matrix form using as.sociomatrix
as.sociomatrix(g,simplify=TRUE) #Returns as-is
as.sociomatrix(g,simplify=FALSE) #Returns as list
as.sociomatrix(net) #Coerces to matrix
as.sociomatrix(list(net,g)) #Returns as list of matrices