[R] multiple "next" in for loops?

Kinoko andzsinszan at gmail.com
Wed Nov 12 03:22:25 CET 2008


from the top of my head (ugly but works).
jumps 5 if i==2 or i==8


j = 0
for(i in 1:15){
    if((i==2)||(i==8)){
        print(i)
        j=i+5
        next
    }
    if (i>=j){
        print(i)
    }else{
        next
    }
}



More information about the R-help mailing list