Identifies sequential residence events where detected movement between stations may be due to drifting of an expelled tag or dead animal.

drift(
  data,
  type,
  ID,
  station,
  res.start = "auto",
  res.end = "auto",
  residences = "auto",
  units = "auto",
  ddd,
  from.station,
  to.station,
  cutoff = NULL,
  cutoff.units = NULL,
  verbose = TRUE
)

Arguments

data

a data frame of residence events. Residence events must include tag ID, location name, start time, and end time.

type

the method used to generate the residence events in data. Options are "mort", "actel", "glatos", "vtrack", or "manual". If "manual", then user must specify ID, station, res.start, and res.end.

ID

a string of the name of the column in data that holds the tag or sample IDs.

station

a string of the name of the column in data that holds the station name or receiver location.

res.start

a string of the name of the column in data that holds the start date and time. Must be specified and in POSIXt or character in the format YYYY-mm-dd HH:MM:SS if type="manual".

res.end

a string of the name of the column in data that holds the end date and time. Must be specified and in POSIXt or character in the format YYYY-mm-dd HH:MM:SS if type="manual".

residences

a character string with the name of the column in data that holds the duration of the residence events.

units

units of the duration of the residence events in data.

ddd

a dataframe of stations/locations where detected movement between stations may be due to drifting of an expelled tag or dead animal.

from.station

a string of the name of the column in data that contains the station/location names where drifting detections may start from.

to.station

a string of the name of the column in data that contains the station/location names where drifting detections may move to.

cutoff

the maximum allowable time difference between detections to be considered a single residence event. Default is NULL.

cutoff.units

the units of the cutoff. Options are "secs", "mins", "hours", "days", and "weeks".

verbose

option to display progress bar as drift is applied. Default is TRUE.

Value

A data frame with one row for each residence event. Format is the same as the input residence events, but events that may be due to dead drift are combined into single residence events.

Examples

# With no drift:
head(events)
#>        ResidenceStart Station.Name ID        ResidenceEnd ResidenceLength.days
#> 1 2003-09-21 23:49:45           11  A 2003-09-22 00:08:18           0.01288194
#> 2 2003-09-22 00:20:28            1  A 2003-09-22 00:50:36           0.02092593
#> 3 2003-09-24 16:56:36            1  A 2003-10-11 17:15:47          17.01332176
#> 4 2003-10-25 14:27:06            1  A 2003-10-25 14:59:47           0.02269676
#> 5 2003-10-26 16:11:13            1  A 2003-10-26 17:42:09           0.06314815
#> 6 2004-06-23 22:42:20            1  A 2004-06-24 01:15:25           0.10630787

drift.events<-drift(data=events[events$ID=="A",],type="mort",ID="ID",
station="Station.Name",ddd=ddd,from.station="From",to.station="To",
verbose=FALSE)
head(drift.events)
#>        ResidenceStart Station.Name ID        ResidenceEnd ResidenceLength.days
#> 2 2003-09-21 23:49:45        11, 1  A 2003-09-22 00:50:36      0.04225694 days
#> 3 2003-09-24 16:56:36            1  A 2003-10-11 17:15:47     17.01332176 days
#> 4 2003-10-25 14:27:06            1  A 2003-10-25 14:59:47      0.02269676 days
#> 5 2003-10-26 16:11:13            1  A 2003-10-26 17:42:09      0.06314815 days
#> 6 2004-06-23 22:42:20            1  A 2004-06-24 01:15:25      0.10630787 days
#> 9 2004-06-24 17:30:42     14, 8, 2  A 2004-06-25 06:47:40      0.55344907 days

# With cutoff:
drift.events<-drift(data=events[events$ID=="A",],type="mort",ID="ID",
station="Station.Name",ddd=ddd,from.station="From",to.station="To",
cutoff=1,cutoff.units="days",verbose=FALSE)
head(drift.events)
#>        ResidenceStart Station.Name ID        ResidenceEnd ResidenceLength.days
#> 2 2003-09-21 23:49:45        11, 1  A 2003-09-22 00:50:36      0.04225694 days
#> 3 2003-09-24 16:56:36            1  A 2003-10-11 17:15:47     17.01332176 days
#> 4 2003-10-25 14:27:06            1  A 2003-10-25 14:59:47      0.02269676 days
#> 5 2003-10-26 16:11:13            1  A 2003-10-26 17:42:09      0.06314815 days
#> 6 2004-06-23 22:42:20            1  A 2004-06-24 01:15:25      0.10630787 days
#> 9 2004-06-24 17:30:42     14, 8, 2  A 2004-06-25 06:47:40      0.55344907 days