rad2idx: Transform radians to sequential index values

Description Usage Arguments Details Value Author(s) References Examples

View source: R/rad2idx.R

Description

Transform radian values to the nearest corresponding indices of the original data.

Usage

1
rad2idx(r, spc)

Arguments

r

A vector of numeric values representing dates in radians.

spc

A numeric value indicating the number of samples per cycle (e.g., samples per year).

Details

rad2idx finds the corresponding indices for each element of r.

Value

Returns the index values corresponding to r.

Author(s)

Bjorn J. Brooks, Danny C. Lee, William W. Hargrove, Lars Y. Pomara

References

Brooks, B.J., Lee, D.C., Desai, A.R., Pomara, L.Y., Hargrove, W.W. (2017). Quantifying seasonal patterns in disparate environmental variables using the PolarMetrics R package.

Examples

1
2
3
4
5
6
7
dpy <- 365                 # Days/year
spy <- 46                  # Samples/year (or samples/cycle)
data(mndvi)                # Load data
t <- as.vector(mndvi$day)  # Days since January 1, 2000
r <- t2rad(t, dpc=dpy)     # Transform days of year to radians
r_idx <- rad2idx(r, spc=spy) # Indices corresponding to radial angles in r
head(cbind(t,r,r_idx))     # Compare results

bjornbrooks/PolarMetrics documentation built on Dec. 22, 2020, 1:42 a.m.