pr_latency_reach: Computes the latency to reach one or several antennas

View source: R/pr_latency_reach.R

pr_latency_reachR Documentation

Computes the latency to reach one or several antennas

Description

This function computes, for every individual, the latency to reach (i.e. be read at) certain antennas. This can for example be used in the context of an exploration test, in which individuals enter an exploration box, in which they are read by certain antennas.

The function computes the difference between the initial time (time at which the antennas were introduced/started to record) and the first read at one or several antennas of interest. Individuals that were not read at these antennas (notably obtained from block_ref_df) receive a score corresponding to the maximal possible duration by default.

Usage

pr_latency_reach(
  block_df,
  block_ref_df,
  antenna_nb,
  start_time,
  end_time,
  keep_NA = FALSE,
  unit = "m"
)

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.

antenna_nb

If there is one antenna of interest, then antenna_nb corresponds to its number/name (antenna_nb_1 in examples). However, if there are several antennas of interest, the argument should be a vector of antenna names/numbers (antenna_nb_2 in 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).

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.

unit

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

Value

A data frame containing the latency, for every individual, to enter the antenna(s) of interest.

Examples


data(block_df)
data(block_ref_df)
antenna_nb_1 <- 44
antenna_nb_2 <- c(41, 42, 43, 44)
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_reach(
#block_df,
#block_ref_df,
#antenna_nb_2,
#start_time,
#end_time,
#keep_NA = T,
#unit = 's')

#pr_latency_reach(
#block_df,
#block_ref_df,
#antenna_nb_1,
#start_time,
#end_time,
#keep_NA = T,
#unit = 'm')

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