library(oce)
true <- 355
a <- true + rnorm(100, sd = 10)
a <- ifelse(a > 360, a - 360, a)
a2 <- unwrapAngle(a)
par(mar = c(3, 3, 5, 3))
hist(a, breaks = 360)
abline(v = a2$mean, col = "blue", lty = "dashed")
abline(v = true, col = "blue")
mtext("true (solid)\n estimate (dashed)", at = true, side = 3, col = "blue")
abline(v = mean(a), col = "red")
mtext("mean", at = mean(a), side = 3, col = "red")
Run the code above in your browser using DataLab