R/fm_duration_rest.R

Defines functions fm_duration_rest

Documented in fm_duration_rest

## Calculating the duration of flight and rest
#' @name fm_duration_rest
#' @title Calculate the duration and rest for flight bouts
#' @description Calculates the rest and flight duration for each bout in a flight mill
#' @param df Data frame to be modified. Use the data frame created from bouts function
#' @param bout The bout vector created from the bouts function.
#' @return A data frame with the bout flight parameters for the specified flight mill
#' @export

fm_duration_rest <- function(df, bout) {
  df <- df %>%
    dplyr::group_by(bout) %>%
    dplyr::summarise(total_flight_duration = sum(duration)) %>%
    tidyr::spread(bout, total_flight_duration) %>%
    dplyr::rename(total_flight_duration_sec = "TRUE")
}
JayeNewman/flightmill documentation built on Jan. 3, 2022, 12:20 a.m.