Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204715

Varying the number of iterations in a for loop depending on results in the body of the for loop in R

$
0
0

Here is the code that I tried, to vary my iterations in a for loop

repscount <- value
for (i in 1:repscount) { 
  ##certain calculations on x
  if (x == 0) {repscount <- repscount + 1} else{}##add x to a list
}

But my repscount does not increase. Does is rewrite the value of repscount? Is there another way of doing this without using a while loop?


Viewing all articles
Browse latest Browse all 204715

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>