Description Usage Arguments Details Value See Also Examples
View source: R/date_to_triangle.R
Use dates of events and dates of birth to create one-year Lexis triangles.
1 | date_to_triangle_year(date, dob, month_start = "Jan")
|
date |
Dates of events.
A vector of class |
dob |
Dates of birth.
A vector of class |
month_start |
An element of |
See vignette("demprep")
for the definition
of Lexis triangles.
date
and dob
must have the same length,
unless one of them has length 1, in which case the
length-1 argument is recycled.
Periods start on the first day of month_start
,
and end one-year-minus-one-day later.
The default value for month_start
is "Jan"
,
so periods by default start on 1 January and
end on 31 December.
A character vector with the same length as date
.
The output from date_to_triangle_year
is often processed further using function
format_triangle_year
.
Other functions for creating
triangles from dates are
date_to_triangle_quarter
and date_to_triangle_month
.
Other functions for creating one-year
units from dates are
date_to_age_year
.
date_to_period_year
, and
date_to_cohort_year
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | date_to_triangle_year(date = c("2024-03-27",
"2022-11-09"),
dob = "2020-01-01")
## starts on 1 July rather than 1 January
date_to_triangle_year(date = c("2024-03-27",
"2022-11-09"),
dob = "2020-01-01",
month_start = "Jul")
## events occurring to people born during the
## period in question are always allocated to
## lower Lexis triangles
date_to_triangle_year(date = c("2020-03-19",
"2020-06-18"),
dob = c("2020-03-01",
"2020-06-18"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.