Small helpers for the circ_gam data contract: the response, and
any angular covariate entering a cyclic smooth, must be in radians. rad
converts to radians from a named or numeric period, deg converts radians
to degrees, and wrap folds angles to a single branch with
atan2(sin, cos) (exact and NA-safe).
Usage
rad(x, from = "degrees")
deg(x)
wrap(x, to = c("pi", "2pi"))Arguments
- x
A numeric vector of angles.
- from
For
rad, the period of the input scale: one of"degrees"(360),"gradians"(400),"turns"(1),"radians"(a no-op), or any positive numeric period – e.g.24for hour-of-day,12for month.- to
For
wrap, the target branch:"pi"for \((-\pi, \pi]\) (the tan-half branch) or"2pi"for \([0, 2\pi)\).