states2prop_time_active: Calculate proportion of time in state active

View source: R/states2prop_time_active.R

states2prop_time_activeR Documentation

Calculate proportion of time in state active

Description

states2prop_time_active calculates the proportion of time in state active for each animal_tag and day.

Usage

states2prop_time_active(active_states, activity_gaps, gps = NULL,
  pos = NULL, dayshift = "sunrise", dawn_degree = 12,
  period = "day", max_na = 0)

Arguments

active_states

A data.table with the predicted active states (return of function thresholds2states.

activity_gaps

A data.table with the identified gaps in the activity data (return of function identify_activity_gaps.

gps

A data.table with the GPS positions (at least one) of the animals. The table should contain the columns: <animal_tag>, <longitude>, <latitude>.

pos

A vector containing longitude and latitude of the research area. This parameter is only necessary when no GPS-positions are provided or when the GPS-positions for some animals are missing.

dayshift

Either "sunrise" or "dawn". Defines when consecutive days are separated so that each day contains one complete night and one complete day. The identifier for each day is called <date_se> for sunrise and <date_dawn> for dawn.

dawn_degree

An integer between 0 and 90 that defines the angle of the sun below the horizon at dawn and dusk.

period

Either "day" or "week", specifies the period of time in which the proportion of time in state active is aggregated.

max_na

An integer with the maximum number of minutes with NA that are allowed for each period. When this threshold is crossed proportion of time in state active will be set to NA for this period.

Value

A data.table with the proportion of time in state active for each animal_tag and day. The proportion of time in state active is returned for the whole day <total>, during daytime <day> (sunrise till sunset), during nighttime <night> (dusk till dawn), during dusk <dusk> (sunset till the sun reaches dawn_degree),during dawn <dawn> ()

Examples

states2prop_time_active(active_states = active_states_a,
                                  activity_gaps = activity_data_gaps,
                                  gps = gps_data,
                                  dayshift = "sunrise",
                                  dawn_degree = 12,
                                  period = "day"
                                  max_na = 30)


maxkroeschel/activitytools documentation built on July 31, 2023, 1:34 p.m.