Mean angle in degrees

mean_degrees(x, seed = 1, ...)

Arguments

x

numeric vector of angles in degrees.

seed

numeric value used as a random seed for reproducibility. This seed affects the random value added to x in the form rnorm(length(x)) * 1e-6.

...

additional arguments are ignored.

Value

numeric angle in degrees representing the mean angle of input angles in degrees from x. An attribute "radius" included with the unit radius from the mean unit vectors. This radius may be useful as a sort of weight factor.

Details

Simple utility function to calculate the mean angle in degrees using vector directional logic. For each angle, a unit vector is created with radius 1, then the mean point is used to define the new angle.

A small random value is added to each input value to reduce the effect of having identical opposite angles. In that case, the output is a right angle to the input angles.

Examples

mean_degrees(c(355, 15))
#> [1] 5
#> attr(,"radius")
#> [1] 0.9848078

mean_degrees(c(355, 15, 10))
#> [1] 6.683256
#> attr(,"radius")
#> [1] 0.9890302

mean_degrees(c(0, 180))
#> [1] 270
#> attr(,"radius")
#> [1] 7.069431e-09

mean_degrees(c(0, 270))
#> [1] 315
#> attr(,"radius")
#> [1] 0.7071068