title: Why is using `<<-` frowned upon and how can I avoid it?
body: <p>I followed the discussion over <a href="https://stackoverflow.com/questions/9730651/how-to-avoid-by-using-assign">HERE</a> and am curious why is using<code>&lt;&lt;-</code> frowned upon in R. What kind of confusion will it cause?</p>
  
  <p>I also would like some tips on how I can avoid <code>&lt;&lt;-</code>. I use the following quite often. For example:</p>
  
  <pre><code>### Create dummy data frame of 10 x 10 integer matrix.
  ### Each cell contains a number that is between 1 to 6.
  df &lt;- do.call("rbind", lapply(1:10, function(i) sample(1:6, 10, replace = TRUE)))
  </code></pre>
  
  <p>What I want to achieve is to shift every number down by 1, i.e all the 2s will become 1s, all the 3s will be come 2 etc. Therefore, all <code>n</code> would be come <code>n-1</code>. I achieve this by the following:</p>
  
  <pre><code>df.rescaled &lt;- df
  sapply(2:6, function(i) df.rescaled[df.rescaled == i] &lt;&lt;- i-1))
  </code></pre>
  
  <p>In this instance, how can I avoid <code>&lt;&lt;-</code>?  Ideally I would want to be able to pipe the sapply results into another variable along the lines of:</p>
  
  <pre><code>df.rescaled &lt;- sapply(...)
  </code></pre>