These functions provide basic summary statistics for headings
that are commonly used. For more advanced statistics on circular data,
use hdg_circular() and the
circular package.
hdg_mean(hdg, weights = 1, na.rm = FALSE)
hdg_diff(hdg, hdg_ref)
hdg_sd(hdg, weights = NULL, na.rm = FALSE, bootstrap_n = 100)A heading in degrees, where 0 is north,
90 is east, 180 is south, and 270 is west. Values
outside the range [0-360) are coerced to this range
using hdg_norm().
Optional weights for each value. Note that for hdg_sd()
this will trigger a bootstrap estimation as there is no clear way to
apply a weighted standard deviation to circular data.
Use TRUE to remove missing values
A reference heading against which
to compare hdg.
For weighted standard deviation, the number of bootstrap replicates.
hdg_mean(-10:10)
#> [1] 0
hdg_mean(c(350, 10))
#> [1] 0
hdg_diff(350:370, 0)
#> [1] -1.000000e+01 -9.000000e+00 -8.000000e+00 -7.000000e+00 -6.000000e+00
#> [6] -5.000000e+00 -4.000000e+00 -3.000000e+00 -2.000000e+00 -1.000000e+00
#> [11] -1.403342e-14 1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00
#> [16] 5.000000e+00 6.000000e+00 7.000000e+00 8.000000e+00 9.000000e+00
#> [21] 1.000000e+01