coord_time | R Documentation |

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.

coord_time(date.event, random.e = TRUE)

`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. |

A numeric vector of the same length as data.event

@seealso `coord_age`

, `exact_age`

The length of the year is 365 days in non-leap years and 366 days in leap years.

Jose M. Pavia pavia@uv.es

Josep Lledo josep.lledo@uv.es

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

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)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.