| as.sociomatrix {network} | R Documentation |
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.
as.sociomatrix(x, attrname = NULL, simplify = TRUE, ...)
x |
an adjacency matrix, array, network object, or list thereof. |
attrname |
optionally, the name of a network attribute to use for extracting edge values (if x is a network object). |
simplify |
logical; should as.sociomatrix attempt to combine its inputs into an adjacency array (TRUE), or return them as separate list elements (FALSE)? |
... |
additional arguments for the coercion routine. |
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.
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.
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/
~put references to the literature/web site here ~
#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