title: if statement in R can only have one line?
body: <p>I was trying a tiny code with if statement, although it is very simple,but there is something I really confused  here is the code</p>
  
  <pre><code>n&lt;-857
  while(n!=1){
  if(n&lt;=0)
   print("please input a positive integer")
  else if(n%%2==0)
   n&lt;-n/2
   print(n)
  else
   n&lt;-3*n+1
   print(n)
    }
  </code></pre>
  
  <p>as we see  above,when running this code in R, there comes the error,but if I change the if statement like this </p>
  
  <pre><code>if(n&lt;=0)
       print("please input a positive integer")
      else if(n%%2==0)
       n&lt;-n/2
      else
       n&lt;-3*n+1
  </code></pre>
  
  <p>it is ok ,my question is that can we only write one line under each judgement? if I want to do something more after each judge, what should I do ,just like this case, I want to change the value of n,but also want to display it, what should I do? thank you very much</p>