title: What is the difference between `transform` and `within`
body: <p>Reading <a href="https://stackoverflow.com/questions/1295955/what-is-the-most-useful-r-trick">this</a> excellent post i came across <code>within</code> and <code>transform</code>.</p>
  
  <p>Reading both help files i unfortunatly did not fully understand what the differnence is...</p>
  
  <p>I tried something like:</p>
  
  <pre><code>df &lt;- data.frame(A = runif(5), B = rnorm(5))
  A=1:5
  within(df, C&lt;-A+B)
  transform(df,C=A+B)
  </code></pre>
  
  <p>Both times the Output was:</p>
  
  <pre><code>          A          B         C
  1 0.2326266  1.3237210 1.5563476
  2 0.4581693 -0.2605674 0.1976018
  3 0.6431078  0.5920021 1.2351099
  4 0.9682578  1.1964012 2.1646590
  5 0.9889942  0.5468008 1.5357950
  </code></pre>
  
  <p>So both seem to create a new enwironment as they are ignoring <code>A=1:5</code> within the evaluation.</p>
  
  <p>Thanks in advance!</p>