format_triangle_month: Format labels for quarter Lexis triangles

Description Usage Arguments Details Value See Also Examples

View source: R/format_triangle.R

Description

Format labels for one-month Lexis triangles to be used with one-month age groups and periods.

Usage

1
format_triangle_month(x, age, break_max = 1200, open_last = TRUE)

Arguments

x

A vector of Lexis triangle labels.

age

A vector of age groups, the same length as x.

break_max

An integer or NULL. Defaults to 400.

open_last

Whether the final age group has no upper limit. Defaults to TRUE.

Details

age gives the age group to which each triangle in x belongs. All age groups in age must have a width of one month, except for any open age groups.

open_last determines whether the allocation of triangles needs to account for an open age group, and break_max specifies the cut-off for the open age group. See format_age_month for a description of how open_last and break_max control age groups.

When break_max is NULL, the return value from format_triangle_year is identical to x. When break_max is non-NULL, the return value is as follows.

x age return value
"Lower" <= break_max "Lower"
"Lower" > break_max "Upper"
"Lower" NA NA
"Upper" <= break_max "Upper"
"Upper" > break_max "Upper"
"Upper" NA "Upper"
NA <= break_max NA
NA > break_max "Upper"
NA NA NA

Value

A factor with the same length as x.

See Also

Other functions for reformating triangle labels are format_triangle_year, format_triangle_multi, format_triangle_births, and format_triangle_quarter.

date_to_triangle_month creates one-month Lexis triangles from dates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## we construct 'x' and 'age' from
## dates information ourselves before
## calling 'format_triangle_month'
date_original <- c("2024-03-27", "2022-11-09")
dob_original <- "2020-01-01"
x <- date_to_triangle_month(date = date_original,
                            dob = dob_original)
age <- date_to_age_month(date = date_original,
                         dob = dob_original)
format_triangle_month(x = x,
                      age = age)

## someone else has constructed
## 'x' and 'age' from
## dates information
x_processed <- c("Lower", "Lower", "Lower")
age_processed <- c("10", "12+", "5")
format_triangle_month(x = x_processed,
                      age = age_processed,
                      break_max = NULL)

## alternative value for 'break_max'
format_triangle_month(x = x_processed,
                      age = age_processed,
                      break_max = NULL)

johnrbryant/demprep documentation built on Dec. 31, 2021, 11:58 a.m.