circAngles: Convert standard direction angles (in radians relative to the...

Description Usage Arguments Value Examples

View source: R/circAngles.R

Description

This function can be used to convert angular covariates (e.g., ocean currents, wind direction) measured in radians relative to the x-axis to turning angle covariates sutiable for circular-circular regression in fitHMM or MIfitHMM.

Usage

1
circAngles(refAngle, data, coordNames = c("x", "y"))

Arguments

refAngle

Numeric vector of standard direction angles (in radians) relative to the x-axis, where 0 = east, pi/2 = north, pi = west, -pi/2 = south

data

data frame containing fields for the x- and y-coordinates (identified by coordNames) and 'ID' (if more than one individual)

coordNames

Names of the columns of coordinates in data. Default: c("x","y").

Value

A vector of turning angles between the movement direction at time step t-1 and refAngle at time t

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# extract data from momentuHMM example
data<-example$m$data

# generate fake angle covariates
u <- rnorm(nrow(data)) # horizontal component
v <- rnorm(nrow(data)) # vertical component
refAngle <- atan2(v,u)

# add turning angle covariate to data
data$cov3 <- circAngles(refAngle=refAngle,data=data)

momentuHMM documentation built on July 7, 2021, 9:06 a.m.