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".
All 0 or positive values should remain unchanged.
There are many solutions for setting negative values to 0, or to NA, but I can't quite get this working.
Below are examples of my attempts, with dataframe called df and feature called Bearing.
df$Bearing = apply(df$Bearing, 2, function(x){x[x<0] = x[x+360]})
df$Bearing[df$Bearing <0] <- df%Bearing +360
What is the best way to achieve my aim?
ifelse