Skip to contents

Fisher's circular median: the direction minimising the summed angular distance to every observation. Where two directions tie, their mean direction is returned.

Usage

circ_median(x, na_rm = TRUE)

Arguments

x

A numeric vector of angles, in radians.

na_rm

A logical value (default TRUE) determining whether missing values are removed before computing. When FALSE, any NA gives NA.

Value

A single angle in [0, 2*pi), or NA_real_ when there is nothing to summarise.

Examples

circ_median(c(0.1, 0.2, 6.2))
#> [1] 0.1

# unaffected by where the circle is cut
circ_median(c(0.1, 0.2, 6.2) + pi)
#> [1] 3.241593