pr_latency_cross: Computes the latency to cross specific sequences of antennas...

View source: R/pr_latency_cross.R

pr_latency_crossR Documentation

Computes the latency to cross specific sequences of antennas consecutively

Description

Computes the latency to cross specific sequences of antennas consecutively

Usage

pr_latency_cross(
  block_df,
  block_ref_df,
  sequence,
  start_time,
  end_time,
  seq_position = 2,
  unit = "m",
  keep_NA = FALSE
)

Arguments

block_df

A data frame containing the reads from an experimental block

block_ref_df

A data frame containing a reference list with all individuals present in the experimental block.

sequence

Either a vector of antenna numbers/names, or a data frame containing several sequences of the same length (one vector per row), see examples.

start_time

The time from which the experimental block starts (i.e.POSIXct format, see examples).

end_time

The time until which the experimental block lasts (i.e.POSIXct format, see examples).

seq_position

Which antenna, from the sequence of antennas, should be crossed by an animal to calculate the latency? By default, the first read at the second antenna is used to calculate the latency (seq_position = 2). When seq_position = 1, the value will correspond to the first read at the first antenna of the sequence, which might have occurred long before the animal actually crossed the sequence. For example, if the sequence is c(1, 2), the individual can have been read at antenna 1 at 12:00:00, and only cross the sequence later (cross antenna 1 at 12:45:03 and cross antenna 2 at 12:45:05). In the later case, if seq_position = 1, the latency will be computed with 12:00:00, and if seq_position = 2, the latency will be computed with 12:45:05.

unit

Unit of the latency duration: 'm' as default.

keep_NA

Logical argument. If the individuals are never read by the antenna(s), the latency might be set as the maximal possible value, i.e. end_time - start_time (default option), or be kept as NA.

Value

A data frame containing, for each sequence of interest, the latency of each individual to cross it entirely.

Examples

sequence_1 <- as.data.frame(rbind(
 c(41, 42),
 c(41, 43),
 c(41, 44),
 c(42, 41),
 c(42, 43),
 c(42, 44),
 c(43, 41),
 c(43, 42),
 c(43, 44),
 c(44, 41),
 c(44, 42),
 c(42, 43)
))


sequence_2 <- c(43, 42)


start_time <-
 as.POSIXct(strptime(c("2020-11-05 12:30:00"), "%Y-%m-%d %H:%M:%OS"), "UTC")
end_time <-
 as.POSIXct(strptime(c("2020-11-05 15:00:00"), "%Y-%m-%d %H:%M:%OS"), "UTC")

pr_latency_cross(block_df, block_ref_df, sequence_1, start_time, end_time)
pr_latency_cross(block_df, block_ref_df, sequence_2,
start_time, end_time, keep_NA = TRUE, unit = 's')



AparajithaRamesh/pondr documentation built on Sept. 14, 2023, 7:14 p.m.