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)
k=0
do 1 I=1,10000000
n=0
n = rpois(1,16)
if(n(1).eq.0) then
k=k+1
goto 1
endif
m1 = rbinom(2,n(1), 0.25)
m1 = rbinom(2,n(1),0.5)
1 continue
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`)