I'm attempting to add a value (360) to all values within a dataframe column that are below 0. I assumed a simple statement would do. However, all this does is change the values to 360, not add the number to the existing value. I feel the solution is really simple but cant work out what it is. Thanks in advance.
##Example data
ID <- c(1,2,3,4)
val <- c(-180,-150,170,-180)
df <- data.frame (ID,val)
##My attempt
df$val[df$val < 0] <- + 360