dirmn
Directional mean and circular variance
dirmn( x = NULL, y = NULL, origin = c(0, 0), w = NULL, angle = NULL, lonlat = FALSE)The mean direction of a set of directions, the mean resultant length
R (from 0, directions spread evenly, to 1, all the same), the circular
variance 1 - R and the circular standard deviation
sqrt(-2 log R) (Mardia and Jupp 2000). Directions are given as angles,
or as points seen from an origin (the directions of incidents from an
offender’s base, say). The mean direction of points depends on the
origin chosen. That R lies in [0, 1] is proved in Lean: see
proof("dirmn").
Parameters
Section titled “Parameters”x, yThe points:
xandynumeric vectors of equal length; orxa matrix or data frame with columns namedxandy(orXandY, assf::st_coordinates()names them, orlonandlatwithlonlat = TRUE) andyNULL; orxan sf or sfc object of POINT geometries, whose coordinate reference system must agree withlonlat. An unnamed two-column matrix is read asxtheny; other columns are never taken by position. Vectors given separately (x,y, andwortwhere a function takes them) are matched by name when every one is named and no name repeats, as elsewhere in the package; otherwise by position. No missing or infinite values.originFor points: the origin
c(x, y)(in degrees whenlonlat = TRUE); no point may lie on it.wNULL, or one weight from 0 per direction, positive sum.angleInstead of points: angles in radians, anticlockwise from east (the x axis).
lonlatFALSE(the default) whenxandyare planar coordinates in one length unit;TRUEwhen they are longitude and latitude in degrees, which are then projected to metres byeqproj()about their own centre, and centres are returned in degrees. It is never guessed.
Returns
Section titled “Returns”A named numeric vector: theta (the mean direction in radians
anticlockwise from east, in [0, 2 pi); NaN when R is 0),
bearing (the same as a compass bearing, degrees clockwise from
north), r, var, sd, w (the total weight) and n.
References
Section titled “References”Mardia, K. V. and Jupp, P. E. (2000). Directional Statistics. Wiley. doi:10.1002/9780470316979
Examples
Section titled “Examples”dirmn(c(1, 2, 0), c(1, 1, 3), origin = c(0, 0))dirmn(angle = c(0.1, 0.2, 6.2))Generated from the R help page: dirmn in the R reference.