title: R if-else not working
body: <p>What is wrong with this if-else in my R program?</p>
  
  <pre><code>if(is.na(result)[1])
      print("NA")
  else
      coef(result)[[1]]
  </code></pre>
  
  <p>I'm getting an error:</p>
  
  <pre><code>&gt; if(is.na(result)[1])
  +   print("NA")
  &gt; else
  Error: unexpected 'else' in "else"
  &gt;   coef(result)[[1]]
  </code></pre>
  
  <p>So then I added curly braces around the if and the else and now I get this error:</p>
  
  <pre><code>&gt; if(is.na(result)[1]) {
  +     print("NA")
  Error: unexpected input in:
  "if(is.na(result)[1]) {
  ¬"
  &gt; } else {
  Error: unexpected '}' in "}"
  &gt;     coef(result)[[1]]
  Error: unexpected input in "¬"
  &gt; }
  Error: unexpected '}' in "}"
  </code></pre>