library(oce)
# fake some heading data that lie near due-north (0 degrees)
n <- 20
heading <- 360 + rnorm(n, sd=10)
heading <- ifelse(heading > 360, heading - 360, heading)
x <- 1:n
plot(x, heading, ylim=c(-10, 360), type="l", col="lightgray", lwd=10)
lines(x, angleRemap(heading))
Run the code above in your browser using DataLab