visits: Visits

View source: R/transformations.R

visitsR Documentation

Visits

Description

Raw data from RFID loggers contain multiple reads per individual simply because the individual sat there long enough. In visits() these reads are collapsed into one visit.

Usage

visits(
  r,
  bw = 3,
  allow_imp = FALSE,
  bw_imp = 2,
  na_rm = FALSE,
  pass = TRUE,
  allow.imp,
  na.rm
)

Arguments

r

Dataframe. Contains raw reads from an RFID reader with colums animal_id, logger_id, time.

bw

Numerical. The minimum interval, in seconds, between reads for two successive reads to be considered separate visits.

allow_imp

Logical. Whether impossible visits should be allowed (see details).

bw_imp

Numerical. The minimum number of seconds required to travel between loggers. If quicker, visits considered impossible.

na_rm

Logical. Whether NA values should be automatically omited. Otherwise an error is returned.

pass

Logical. Pass 'extra' columns through the function and append them to the output.

allow.imp, na.rm

Depreciated.

Details

Visits are defined by three pieces of data:

  • How much time has passed between reads (bw)

  • A change in identity between two successive reads (animal_id)

  • A change in logger for a single individual (logger_id)

The function will return an error if impossible visits are detected (unless allow_imp = TRUE) . A visit is deemed impossible if a single animal travels between loggers in less time than specified by bw.

Value

A data frame with visits specifying animal_id and logger_id as well as the start and end of the visit. Any extra columns that are unique at the level of animal_id or logger_id will also be passed through (i.e. age, sex, logger location, etc.).

Examples

v <- visits(finches)
head(v)

v <- visits(finches, bw = 30)
head(v)

# Calculate across different experiments:
library(dplyr)
v <- chickadees %>%
  group_by(experiment) %>%
  do(visits(.))


steffilazerte/feedr documentation built on Jan. 27, 2023, 3:46 a.m.