title: What's the difference in using a semicolon or explicit new line in R code
body: <p>I originally thought that the semicolon <code>;</code> was the equivalent to adding an explicit new line, e.g.</p>
  
  <pre><code>x &lt;- 1; y &lt;- 2
  </code></pre>
  
  <p>is the same as</p>
  
  <pre><code>x &lt;- 1
  x &lt;- 2
  </code></pre>
  
  <p>Certainly the <a href="http://cran.r-project.org/doc/manuals/r-devel/R-lang.html" rel="noreferrer">R documentation</a> doesn't seem to make a distinction with respect to syntactically complete statements:</p>
  
  <blockquote>
    <p>Both semicolons and new lines can be used to separate statements. A
    semicolon always indicates the end of a statement while a new line may
    indicate the end of a statement. If the current statement is not
    syntactically complete new lines are simply ignored by the evaluator.</p>
  </blockquote>
  
  <p>However, I found that at least in Rstudio Server, the semicolon behaves differently to a new line. For example:</p>
  
  <pre><code>&gt; temp_a ; temp_b &lt;- 1 ; temp_c &lt;- 2
  Error: object 'temp_a' not found
  &gt; exists("temp_b")
  [1] FALSE
  &gt; exists("temp_c")
  [1] FALSE
  </code></pre>
  
  <p>compared to </p>
  
  <pre><code>&gt; temp_a
  Error: object 'temp_a' not found
  &gt; temp_b &lt;- 1
  &gt; temp_c &lt;- 2
  &gt; 
  &gt; exists("temp_b")
  [1] TRUE
  &gt; exists("temp_c")
  [1] TRUE
  </code></pre>
  
  <p>Why does this happen? Are there any other gotchas I should look out for?</p>