Description Usage Arguments Value Examples
View source: R/segmentation_helper_functions.R
Convert movement variables from continuous to discrete values for analysis by
segment_behavior
.
1 | discrete_move_var(dat, lims, varIn, varOut)
|
dat |
A data frame that contains the variable(s) of interest to convert from continuous to discrete values. |
lims |
A list of the bin limits for each variable. Each element of the list should be a vector of real numbers. |
varIn |
A vector of names for the continuous variable stored as columns
within |
varOut |
A vector of names for the storage of the discrete variables returned by the function. |
A data frame with new columns of discretized variables as labeled by
varOut
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #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")
#round times to nearest interval of interest (e.g. 3600 s or 1 hr)
tracks<- round_track_time(dat = tracks, id = "id", int = 3600, tol = 180, time.zone = "UTC",
units = "secs")
#create list from data frame
tracks.list<- df_to_list(dat = tracks, ind = "id")
#filter observations to only 1 hr (or 3600 s)
tracks_filt.list<- filter_time(dat.list = tracks.list, int = 3600)
#define bin number and limits for turning angles and step lengths
angle.bin.lims=seq(from=-pi, to=pi, by=pi/4) #8 bins
dist.bin.lims=quantile(tracks[tracks$dt == 3600,]$step,
c(0,0.25,0.50,0.75,0.90,1), na.rm=TRUE) #5 bins
# Assign bins to observations
tracks_disc.list<- purrr::map(tracks_filt.list,
discrete_move_var,
lims = list(dist.bin.lims, angle.bin.lims),
varIn = c("step", "angle"),
varOut = c("SL", "TA"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.