title: I faced the missing value where TRUE/FALSE needed error
body: <pre><code>   for(i in 1:length(data)){
        randomselector&lt;-0
        
        sumofdegreesequence&lt;-sum(data)
        
        randomselector&lt;-runif(n=1,min=0,max=1) 
        if(i!=minindex){
        for(j in 1:length(data)){
          if(randomselector&lt;((sum(data[1:j]))/sumofdegreesequence)){ ##Error line
            selectednextvertex&lt;-j
          }else{
            j&lt;-j
          }
        }
        data[minindex]&lt;-data[minindex]-1
        data[selectednextvertex]&lt;-data[selectednextvertex]-1
        }else{
          i&lt;-i
        }
        
        if(data[minindex]==0){
          
          break
        }
        
      }
  </code></pre>
  <p>I am getting missing value where TRUE/FALSE Needed and my data is</p>
  <pre><code>data&lt;-c(4,4,3,3,2,1,1,2). 
  </code></pre>
  <p>I tried different things and I couldn't solve the problem</p>