insert_NAs {bayesmove}R Documentation

Insert NA gaps to regularize a time series

Description

Insert NA gaps to regularize a time series

Usage

insert_NAs(data, int, units)

Arguments

data

A data frame that minimally contains columns for animal ID, date, and time step. These must be labeled id, date, and dt, respectively, where date is of class POSIXct.

int

integer. An integer that characterizes the desired interval on which to insert new rows.

units

character. The units of the selected time interval int, which can be selected from one of "secs", "mins", "hours", "days", or "weeks".

Value

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.

Examples

#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")



[Package bayesmove version 0.2.0 Index]