R/segmentation_helper_functions.R
prep_data.Rd
Calculates step lengths, turning angles, and net-squared displacement 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.
prep_data(dat, coord.names, id)
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 in a 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.
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.
character. The name of the column storing the animal IDs.
A data frame where all original data are returned and new columns are
added for step length (step
), turning angle (angle
),
net-squared displacement (NSD
), and time
step (dt
). Names for coordinates are changed to x
and
y
. Units for step
and NSD
depend on the projection of the
coordinates, angle
is returned in radians, and dt
is
returned in seconds.