title: How to replace negative values in a dataframe column with a different value
body: <p>I have a large dataframe in R with close to one million rows and 91 columns. For one particular column, I need to replace all negative values with "the value + 360". </p>
  
  <p>All 0 or positive values should remain unchanged. </p>
  
  <p>There are many solutions for setting negative values to 0, or to NA, but I can't quite get this working. </p>
  
  <p>Below are examples of my attempts, with dataframe called <code>df</code> and feature called <code>Bearing</code>.</p>
  
  <pre><code>df$Bearing = apply(df$Bearing, 2, function(x){x[x&lt;0] = x[x+360]})
  
  df$Bearing[df$Bearing &lt;0] &lt;- df%Bearing +360
  </code></pre>
  
  <p>What is the best way to achieve my aim?</p>