How can i Stop specific vector to not update in if statement?

How can i Stop specific vector to not update in if statement?
0

#1

This is my code and I am using R.

In this code, I don’t want to update O i.e Rowsums(E). I want it to use always the same O in each iteration.

I also try to store O as a vector O <- c(500, 200, 1600, 800) but the answer goes Inf. I think the If statement is the problem causing.

How can I solve this issue?

`E <- matrix(c(200,100,300,100,100,100,300,0,0,0,600,200,200,0,400,500), nrow = 4, ncol = 4)

iteration=0 
repeat{
  O <- rowSums(E) 
  R <- colSums(E)

  Po <- R/O

  E1 <- Po*E

  R1 <- colSums(E1)

  if (sum(abs(R1-R))<=0.01) break   

  R=R1  
  E=E1  
  O <- rowSums(E)
  iteration=iteration+1 
}`