convert Fortran goto statement in to R

hi, could you please someone help me, in the following code how I can write the goto in the if statement in Rstudio.
This code in Fortran77.
Thank you.

    integer n(1)
do 1 I=1,10000000
        n = rpois(1,16)
      if(n(1).eq.0) then
	goto 1
	m1 = rbinom(2,n(1), 0.25)
	m1 = rbinom(2,n(1),0.5)
  1	continue

Maybe you could change the title of the post so that it is more useful. Something like 'convert Fortran goto statement in to R'.

Okay, I changed the title of my question. Thank you.

No worries. I don't know Fortran, but hopefully someone else does.

Hi @Alhejaili ,
The goto 1 statement breaks the loop when the if(....) condition is met, and effectively sends the loop to the next value of I via line 1 (continue). You achieve the same thing in an R loop with a next statement inside a corresponding if statement.
See help(`if`)

Thank you, I appreciate your help

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.