Find the maximum duration of a single residence in the dataset that occurred before a station change (i.e., the animal can be assumed to be alive)
resmax(
data,
ID,
station,
res.start,
residences,
stnchange,
drift = FALSE,
verbose = TRUE
)a dataframe of residence events. Residence events must include tag ID, location name, start time, and duration.
a string of the name of the column in data that holds the tag or
sample IDs.
a string of the name of the column in data that holds the
station name or receiver location.
a string of the name of the column in data that holds the
start date and time. Must be specified and in POSIXt if type="manual".
a character string with the name of the column in data
that holds the duration of the residence events.
a dataframe with the start time and location of the most
recent station or location change. Must use the same column names as data.
indicates if drift residence events should be included in determining the maximum residence duration
option to display progress bar as function is run. Default is TRUE.
a dataframe with the residence information for the longest residence for each tag ID that occurred before the most recent station/location change.
# Identify most recent station change
station.change<-stationchange(data=events,type="mort",ID="ID",
station="Station.Name",verbose=FALSE)
longest_res_events<-resmax(data=events,ID="ID",station="Station.Name",
res.start="ResidenceStart",residences="ResidenceLength.days",
stnchange=station.change,verbose=FALSE)
head(longest_res_events)
#> ResidenceStart Station.Name ID ResidenceEnd
#> 3 2003-09-24 16:56:36 1 A 2003-10-11 17:15:47
#> 68 2003-09-13 13:25:38 4 C 2003-10-07 16:26:06
#> 112 2003-08-16 22:35:23 1 G 2003-08-18 12:05:20
#> 229 2003-07-22 21:48:42 18 H 2003-09-21 12:08:52
#> 821 2003-01-31 19:47:16 8 I 2003-02-06 18:59:34
#> 847 2005-08-14 05:01:50 4 J 2005-10-09 18:55:58
#> ResidenceLength.days
#> 3 17.013322
#> 68 24.125324
#> 112 1.562465
#> 229 60.597338
#> 821 5.966875
#> 847 56.579259