goto to direct to specific line

How to use goto statement in R?

like direct any condition to any line in R.

R doesn't have goto, but there is a discussion of alternatives in the thread below:
https://r.789695.n4.nabble.com/quot-Goto-quot-loop-td839837.html

From Peter Daalgard's response:

It doesn't exist, but it can always be replaced by if() {} else {}
constructs. (You don't usually see goto in the class of "functional
programming languages" to which R belongs. See also
http://en.wikipedia.org/wiki/Edsger_W._Dijkstra .)

R does have break, next, and return() which cover some common cases
where goto might be used with some reason.

I recommend looking directly at the thread, though, as there's more detailed discussion.

2 Likes

@mara Thankyou for the information.

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