Learn R Programming

qlifetable (version 0.0.1-13)

coord_time: 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)

Value

A numeric vector of the same length as data.event

@seealso coord_age, exact_age

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.

Author

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. tools:::Rd_expr_doi("10.1111/rssa.12769")

Examples

Run this code
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)

Run the code above in your browser using DataLab