R/get_times.R

Defines functions get_seq get_expected get_actual

Documented in get_actual get_expected get_seq

#' Set up timestamps for RAW or IMU data frames
#' @rdname get_times
#' @inheritParams get_parameters
#' @inheritParams read_gt3x
#' @keywords internal
get_actual <- function(packets, tz) {

  packets %>%
  sapply("[[", "timestamp") %>%
  anytime::anytime(tz)

}

#' @rdname get_times
#' @param start start time
#' @param end end time
#' @param samp_rate sampling rate
#' @keywords internal
get_expected <- function(start, end, samp_rate) {

  list(
    expected_full = get_seq(start, end, samp_rate),
    expected_floor = get_seq(start, end, 1)
  )

}

#' @rdname get_times
#' @keywords internal
get_seq <- function(start, end, samp_rate) {

  seq(start, end, 1/samp_rate) %>%
  .[-length(.)]

}

Try the AGread package in your browser

Any scripts or data that you put into this service are public.

AGread documentation built on Sept. 13, 2022, 5:06 p.m.