convert_asnipe: Convert data for use in two asnipe functions

View source: R/convert.R

convert_asnipeR Documentation

Convert data for use in two asnipe functions

Description

Converts raw RFID data into a format for easy use by either the asnipe::gmmevents() or the asnipe::get_associations_points_tw() functions included in the asnipe package for calculating group membership.

Usage

convert_asnipe(r, fun = "gmmevents", by_day = TRUE, time_scale = "secs")

Arguments

r

Dataframe. Raw RFID dataset. Must have at least columns animal_id, logger_id and time. The column time should be formated as POSIXct (data/time). (Consider using load_format() to format your dataframe)

fun

Which asipe function should the data be formated for? asnipe::gmmevents() or asnipe::get_associations_points_tw().

by_day

Logical. The asnipe::gmmevents() function suggests that locations are split into sublocations defined by the scale at which one might see temporal gaps in the data (e.g., by day as diurnal species are not active at night). If by_day = TRUE, logger_ids (locations) will be split into unique locations by date (e.g., 2200 would become 2200_2016-10-28, 2200_2016_10-29, etc.). See asnipe::gmmevents() for more details. Ignored if the get_associations_points_tw function is selected.

time_scale

Character. The asnipe::gmmevents() function suggests that the time data should be at a scale relevant to the definition of group membership. For birds in flocks visiting feeders, seconds are appropriate. Values can be any specified by the base::difftime() function: "auto", "secs", "mins", "hours", "days", "weeks". Ignored if the get_associations_points_tw function is selected.

Value

If fun = "gmmevents", a data frame with three columns, time, identity, and location. Time is converted to the number of seconds or minutes (etc., taken from time_scale) since the first observation.

If fun = "get_associations_points_tw", a data frame with four columns: Date, Time, ID, Location. Date is converted to count starting with 1 as the first day, time is converted to the number of seconds since the first observation.

See Also

asnipe package and it's functions: gmmevents and get_associations_points_tw. https://cran.r-project.org/package=asnipe

Examples


a <- convert_asnipe(finches, fun = "gmmevents")

## Not run: 
library(asnipe)
gmmevents(a$time, a$identity, a$location)

## End(Not run)

a <- convert_asnipe(finches, fun = "get_associations_points_tw")

## Not run: 
library(asnipe)
get_associations_points_bw(a)

## End(Not run)


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