social network analysis, tergm

Hi, and welcome!

It's hard to give a useful answer to this type of question without a reproducible example, called a reprex. It would be necessary to guess at the data structure. In this case, however, reprex doesn't play nice with the code.

I've had to guess that you mean the allyNet list in the alliances dataset in the package. If that is the case, it is a list of lists, or allyNet[1] ... .

> library(xergm)
> library(xergm.common)
> data("alliances")
> class(allyNet)
[1] "list"
> allyNet[1]
$`1981`
 Network attributes:
  vertices = 164 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 625 
    missing edges= 0 
    non-missing edges= 625 

 Vertex attribute names: 
    cinc polity vertex.names year 

No edge attributes

> allyNet[[1]][1,]
  [1] 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
 [64] 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0
[127] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0

The last call returns the vertices list.

To collect them by 5-year increments,

allyNet[1:5]

That just gives you five lists from which you can extract vertices. I'm not sure that's all you're looking for, though.

1 Like