#' Difference between two timestamps.
#'
#' Calculates the difftime between two timestamps.
#'
#' @param df A data frame or tibble.
#' @param stamp1 Timestamp 1
#' @param stamp2 Timestamp 2
#' @param units Units for the difftime function.
#'
#' @return A tibble
#' @export
#'
#'
dog_date_diff <- function(df, stamp1, stamp2, units = "mins"){
stamp1 <- rlang::enquo(stamp1)
stamp2 <- rlang::enquo(stamp2)
name <- paste0(rlang::quo_name(stamp1), "_minus_", rlang::quo_name(stamp2))
out <- df %>%
dplyr::mutate(!!name := as.numeric(difftime(!!stamp1, !!stamp2, units=units)))
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.