R/difference.R

Defines functions diff_dt diff_y.track_xy diff_y diff_x.track_xy diff_x

Documented in diff_x diff_y

#' Difference in x and y
#'
#' Difference in x and y coordinates.
#'
#' @template track_xy_star
#' @template dots_none
#' @return Numeric vector
#' @name diff
#' @export

#' @export
#' @rdname diff
diff_x <- function(x, ...) {
  UseMethod("diff_x", x)
}


#' @export
diff_x.track_xy <- function(x, ...) {
   diff_dt(x$x_)
}

#' @export
#' @rdname diff
diff_y <- function(x, ...) {
  UseMethod("diff_y", x)
}

#' @export
diff_y.track_xy <- function(x, ...) {
   diff_dt(x$y_)
}

diff_dt <- function(x) {
  data.table::shift(x, n = -1) - x
}

Try the amt package in your browser

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

amt documentation built on June 25, 2024, 1:14 a.m.