R/y2d.R

Defines functions y2d

Documented in y2d

#' Convert a time interval from years to days
#'
#' This function takes takes a time interval in years and converts into days,
#' the unit commonly used in time operations in `R`. The simple conversion
#' x * 365 does not work for large number of years, due to the presence of
#' leap years.
#' @param x the number of years of the interval
#' @returns a `difftime` object (in days)
#' @examples
#' y2d(1)
#' y2d(1000)
#'
#' @export

y2d <- function(x) {
  lubridate::date_decimal(x + 1950) - lubridate::date_decimal(1950)
}

Try the tidysdm package in your browser

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

tidysdm documentation built on April 3, 2025, 9:56 p.m.