Description Usage Arguments Value Examples
View source: R/segmentation_helper_functions.R
Insert NA gaps to regularize a time series
1 | insert_NAs(data, int, units)
|
data |
A data frame that minimally contains columns for animal ID, date,
and time step. These must be labeled |
int |
integer. An integer that characterizes the desired interval on which to insert new rows. |
units |
character. The units of the selected time interval |
A data frame where new rows have been inserted to regularize the date
column. This results in values provided for id
, date
, and dt while inserting NAs for all other columns. Additionally, observations with duplicate date-times are removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #load data
data(tracks)
#remove rows to show how function works (create irregular time series)
set.seed(1)
ind<- sort(sample(2:15003, 500))
tracks.red<- tracks[-ind,]
#calculate step lengths, turning angles, net-squared displacement, and time steps
tracks.red<- prep_data(dat = tracks.red, coord.names = c("x","y"), id = "id")
#round times to nearest interval
tracks.red<- round_track_time(dat = tracks.red, id = "id", int = c(3600, 7200, 10800, 14400),
tol = 300, units = "secs")
#insert NA gaps
dat.out<- insert_NAs(tracks.red, int = 3600, units = "secs")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.