circular: Functions for circular descriptive statistics

circularR Documentation

Functions for circular descriptive statistics

Description

Functions for circular descriptive statistics

Usage

circ_mean(x, int, type = c("minusPiPlusPi", "ZeroPlus2Pi"), na.rm = FALSE)

circ_mean_weighted(
  x,
  w,
  int,
  type = c("minusPiPlusPi", "ZeroPlus2Pi"),
  na.rm = FALSE
)

circ_range(x, int, na.rm = FALSE)

circ_sd(x, int, na.rm = FALSE)

Arguments

x

A numeric vector or a matrix. If a data.frame is supplied, then x is coerced to a matrix.

int

A numeric value. The number of units of x in a full circle, e.g., for unit days: int = 365; for unit months: int = 12.

type

A character string. If type == "minusPiPlusPi", then the resulting value lies between -int / 2 and int / 2. If type == "ZeroPlus2Pi", then the resulting value lies between 0 and int.

na.rm

A logical value indicating whether NA values should be stripped before the computation proceeds.

w

A numeric vector. The weights for x, i.e., their length must match the length of x.

Value

A numeric value or NA.

See Also

mean.circular, range.circular, sd.circular

Examples

## Examples with `circ_mean`
x <- 1:3
circ_mean(x, int = 12, type = "minusPiPlusPi") ## expected 2
circ_mean(x, int = 12, type = "ZeroPlus2Pi") ## expected 2
x <- (-2):0
circ_mean(x, int = 12, type = "minusPiPlusPi") ## expected -1
circ_mean(x, int = 12, type = "ZeroPlus2Pi") ## expected 11
x <- (-5):5
circ_mean(x, int = 12, type = "minusPiPlusPi") ## expected 0
circ_mean(x, int = 12, type = "ZeroPlus2Pi") ## expected 12
x <- (-5):8
circ_mean(x, int = 12, type = "minusPiPlusPi") ## expected -4.5
circ_mean(x, int = 12, type = "ZeroPlus2Pi") ## expected 7.5
## Examples with `circ_mean_weighted`
x <- seq_len(12)
w <- c(1, rep(0, 7), 1, 1, 2, 1)
stats::weighted.mean(x, w) ## expected 9
circ_mean_weighted(x, w, int = 12, type = "minusPiPlusPi") ## expected -1
circ_mean_weighted(x, w, int = 12, type = "ZeroPlus2Pi") ## expected 11

DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.