#' Time Difference
#'
#' @description This function takes as in put a numeric time value
#' (\code{t0}) and a vector of numeric time values (\code{times}),
#' and computes the difference in \code{times} relative to \code{t0}.
#'
#' @param t0 numeric scalar indicating the reference time point
#' @param times numeric vector of time points to be converted to
#' time differences (in relation to \code{t0})
#'
#' @return a numeric vector of equal length to \code{times}, containing
#' the computed time differences.
#'
#' @export
#'
#' @examples
#' dt(127, c(0,30,45,87,111, NA, 135, 155))
timeDifference <- function(t0, times){
if(!(is.numeric(t0) & length(t0) == 1)) {
stop("Parameter t0 must be a numeric scalar.")
}
stopifnot(is.numeric(times))
return(t0 - times)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.