title: R: 'Error: unexpected '}' in "}"' --- due to whitespace?
body: <pre><code>foo &lt;- function(x){x*2} 
  </code></pre>
  
  <p>works fine in R Studio while</p>
  
  <pre><code>foo &lt;- function(x){
     x*2
  }
  </code></pre>
  
  <p>gives me the above error?!? I used  to move the code into different lines. Any idea why?</p>
  
  <p>Edit: I am placing this code in the R Studio file editor and hitting "Run." Also </p>
  
  <pre><code>foo &lt;- function(x){
    x*2}
  </code></pre>
  
  <p>returns: Error: unexpected '}' in "x*2}".</p>