title: Storing network via ERGM function: Error: (list) object cannot be coerced to type 'double' in
body: <p>Hi smart people out there! I am trying to create a function of ERGM to obtain the change of network statistics of each network when a random edge is removed.  </p>
  
  <pre><code>Func &lt;- function(network){
  newergm &lt;- ergm(network~edges+ nodematch('court', diff=F,keep=c(1:12,14:16))+nodematch('ideo',diff=F, keep=c(2,4))
                +nodeifactor('issue',base=c(5:9))+nodeifactor('supct')+nodefactor('meritor')
                +nodeifactor('womanpanel'))#, control= control.ergm(MCMC.burnin = 10000,MCMC.interval = 10000,seed=567))
  chgstat &lt;-as.matrix(unlist(summary.statistics(oldergm)-summary.statistics(newergm)))
  return(chgstat)
  }
  </code></pre>
  
  <p>The next step is to write a for loop to storage all the networks each time an edge is removed, here, I am manipulating deleting 3 edges for example, </p>
  
  <pre><code>for(i in 1:3  ){ 
     net3 &lt;- asNetwork(g)     #the origial network from a igraph 
     tempnet[i]&lt;- delete.edges(net3,as.edgelist(net3)[i,])  #create an new network by deleting an edge
     cs[i] &lt;- Func(tempnet[i]) # apply predefined function to each new network
     table &lt;- cbind(cs) 
   }
  </code></pre>
  
  <p>There's no error with the Func, but the for loop keep showing me "Error: (list) object cannot be coerced to type 'double'" I don't understand why it is. This error doesn't occur if I run them without the loops. I am not sure is this the problem of the function or the storage of new networks. Thank you very much for your comments.  </p>