circ_dist: Pairwise Distance Between Two Circular Variables

Description Usage Arguments Value Author(s) Examples

View source: R/circ_dist.R

Description

We define distance between two angles as the minimum of the differences in both clockwise and counterclockwise directions.

Usage

1
circ_dist(y1, y2)

Arguments

y1

A vector of angles.

y2

A vector of angles.

Value

A vector of distances between the angles.

Author(s)

Joyce Hsiao, Matthew Stephens

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Vector of angles.
theta_ref <- seq(0,2*pi, length.out=100)

# Shift the origin of theta_ref to pi.
theta_compare <- shift_origin(theta_ref, origin = pi)
mean(circ_dist(theta_ref, theta_compare))

# After rotation of angles, difference is zero between the original
# and the shifted angles.
theta_compare_rotated <- rotation(ref_var=theta_ref,
    shift_var=theta_compare)
mean(circ_dist(theta_ref, theta_compare_rotated))

jhsiao999/peco documentation built on Nov. 21, 2020, 5:34 p.m.