coord_time {qlifetable} | R Documentation |
Time elapsed (in years) since the beginning of the year
Description
Computes the time(s) elapsed (in years) between the beginning of the year and the date(s) of the event(s). The time coordinate(s) in a Lexis diagram.
Usage
coord_time(date.event, random.e = TRUE)
Arguments
date.event |
A character vector with the dates of events in format either "yyyy-mm-dd" or "yyyy-mm-dd hour:min:secs" (for instance, "2016-01-20 12:00:00") of a population. If "hour:min:secs" is omitted the function imputes either "12:00:00", if 'random.e = FALSE', or a random hour, by default. |
random.e |
A 'TRUE/FALSE' argument indicating whether the exact moment ("hour:min:secs") when the event occurs within the day is randomly selected. This overwrites "hour:min:secs" in 'date.event' even if this has been declared. |
Value
A numeric vector of the same length as data.event
Note
The length of the year is 365 days in non-leap years and 366 days in leap years.
Author(s)
Jose M. Pavia pavia@uv.es
Josep Lledo josep.lledo@uv.es
References
Pavia, JM and Lledo, J (2022). Estimation of the Combined Effects of Ageing and Seasonality on Mortality Risk. An application to Spain. *Journal of the Royal Statistical Society, Series A (Statistics in Society)*, 185(2), 471-497. doi:10.1111/rssa.12769
See Also
Examples
dates <- c("2002-03-23", "2009-04-12", "2019-01-01")
coord_time(dates)
dates <- "2019-01-01 14:00:00"
coord_time(dates, FALSE)