Description Usage Arguments Details Value Author(s) References See Also Examples
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.
1 2 | as.sociomatrix(x, attrname = NULL, simplify = TRUE,
expand.bipartite = FALSE, ...)
|
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. |
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.
Carter T. Butts buttsc@uci.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/
1 2 3 4 5 6 7 8 9 10 11 | #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
|
network: Classes for Relational Data
Version 1.14-377 created on 2019-03-04.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
Mark S. Handcock, University of California -- Los Angeles
David R. Hunter, Penn State University
Martina Morris, University of Washington
Skye Bender-deMoll, University of Washington
For citation information, type citation("network").
Type help("network-package") to get started.
, , 1
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 0 0
[2,] 0 0 1 1 0
[3,] 0 1 1 0 0
[4,] 0 1 1 0 0
, , 2
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 0 1 1
[2,] 1 0 1 0 0
[3,] 0 1 0 0 1
[4,] 0 1 1 1 1
, , 3
[,1] [,2] [,3] [,4] [,5]
[1,] 1 0 0 0 1
[2,] 1 1 1 1 1
[3,] 0 0 1 1 1
[4,] 0 0 1 0 0
, , 4
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 1 1
[2,] 0 0 1 0 1
[3,] 0 1 0 0 0
[4,] 0 1 1 0 0
, , 5
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 0 1
[2,] 0 1 0 0 1
[3,] 0 0 1 1 1
[4,] 0 1 1 1 1
[[1]]
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 0 0
[2,] 1 1 0 1 1
[3,] 1 0 0 1 1
[4,] 0 1 0 1 0
[5,] 0 1 1 1 1
[[2]]
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 0 0
[2,] 0 0 1 0 1
[3,] 1 1 1 1 0
[4,] 1 0 1 0 0
[5,] 0 0 1 1 1
[[3]]
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 1 1 0 1 0
[3,] 1 0 1 0 1
[4,] 0 0 1 0 1
[5,] 0 1 1 0 1
[[4]]
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 1 1 0 1 1
[3,] 1 1 1 1 1
[4,] 0 1 0 0 1
[5,] 0 1 0 0 1
1 2 3 4 5 6
1 0 1 1 1 0 1
2 0 0 0 1 1 0
3 0 0 0 1 1 0
4 0 0 0 0 0 1
5 1 1 0 1 0 0
6 1 0 1 0 0 0
[[1]]
1 2 3 4 5 6
1 0 1 1 1 0 1
2 0 0 0 1 1 0
3 0 0 0 1 1 0
4 0 0 0 0 0 1
5 1 1 0 1 0 0
6 1 0 1 0 0 0
[[2]]
, , 1
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 0 0
[2,] 0 0 1 1 0
[3,] 0 1 1 0 0
[4,] 0 1 1 0 0
, , 2
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 0 1 1
[2,] 1 0 1 0 0
[3,] 0 1 0 0 1
[4,] 0 1 1 1 1
, , 3
[,1] [,2] [,3] [,4] [,5]
[1,] 1 0 0 0 1
[2,] 1 1 1 1 1
[3,] 0 0 1 1 1
[4,] 0 0 1 0 0
, , 4
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 1 1
[2,] 0 0 1 0 1
[3,] 0 1 0 0 0
[4,] 0 1 1 0 0
, , 5
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 0 1
[2,] 0 1 0 0 1
[3,] 0 0 1 1 1
[4,] 0 1 1 1 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.