title: Appropriately using go to algorithm in R
body: <p>I have an algorithm written as follows but I need to write that code into R. I have included the algorithm and the R code. I am not sure if that is represented well enough. To write the R code in the sequential order is not straight forward. I am sorry for not providing all the values of the variables here. I am not sure of the output yet which is the reason I am unable to show the required. It is more of a theoretical question. </p>
  
  <p><strong>Algorithm</strong></p>
  
  <pre><code>         VBDMAX = (va - VG) * 0.79 * (dep / D) ^ -1.21
           VBOWMAX = -0.7 * VBDMAX
           VBOWX = 0
           '  SKIP BOW IF -10D&lt;X&lt;15D OR OUTSIDE EDGE OF BARGES
           If Y &gt; B / 2 Then GoTo 200
           If X &lt; -10 * D Then GoTo 200
           If X &gt;= 15 * D Then GoTo 200
  
           VBOWX = X * VBOWMAX / (10 * D) + VBOWMAX
           If X &lt;= 0 Then GoTo 200
  
           VBOWX = X * (VBDMAX - VBOWMAX) / (5 * D) + VBOWMAX
           If X &lt;= 5 * D Then GoTo 200
           VBOWX = -X * VBDMAX / (10 * D) + 15 * VBDMAX / 10
  200      ' end bow
  </code></pre>
  
  <p><strong>This is the R code that I have written</strong> </p>
  
  <pre><code>VBDMAX = (va - VG) * 0.79 * (dep / D) ^ -1.21
      VBOWMAX = -0.7 * VBDMAX
      VBOWX = 0
      #  SKIP BOW IF -10D&lt;X&lt;15D OR OUTSIDE EDGE OF BARGES
  
      VBOWX &lt;- ifelse ((Y&gt;B/2 | X &lt; -10*D | X&gt;=15*D), 0,X*VBOWMAX/(10*D)+VBOWMAX)
  
      VBOWX &lt;- ifelse (X&lt;=0 , X * (VBDMAX - VBOWMAX) / (5 * D) + VBOWMAX, 
                       ifelse(x &lt;=5*D, -X * VBDMAX / (10 * D) + 15 * VBDMAX / 10))
  </code></pre>