bayesmove (version 0.1.0)

prep_data: Calculate step lengths, turning angles, and time steps

Description

Calculates step lengths and turning angles based on coordinates for each animal ID and calculates time steps based on the date-time. Provides a self-contained method to calculate these variables without needing to rely on other R packages (e.g., adehabitatLT). However, functions from other packages can also be used to perform this step in data preparation.

Usage

prep_data(dat, coord.names, id)

Arguments

dat

A data frame that contains a column for animal IDs, the columns associated with the x and y coordinates, and a column for the date. For easier interpretation of the model results, it is recommended that coordinates be stored after UTM projection (meters) as opposed to unprojected in decimal degrees (map units). Date-time should be of class POSIXct and be labeled date within the data frame.

coord.names

character. A vector of the column names under which the coordinates are stored. The name for the x coordinate should be listed first and the name for the y coordinate second.

id

character. The name of the column storing the animal IDs.

Value

A data frame where all original data are returned and new columns are added for step length (step), turning angle (angle), and time step (dt). Names for coordinates are changed to x and y. Units for step length depend on the projection of the coordinates, turning angles are returned in radians, and time steps are returned in seconds.

Examples

Run this code
# NOT RUN {
#load data
data(tracks)

#subset only first track
tracks<- tracks[tracks$id == "id1",]

#calculate step lengths and turning angles
tracks<- prep_data(dat = tracks, coord.names = c("x","y"), id = "id")

# }

Run the code above in your browser using DataCamp Workspace