vital {vital}R Documentation

Create a vital object

Description

A vital object is a type of tsibble that contains vital statistics such as births, deaths, and population counts, and mortality and fertility rates. It is a tsibble with a special class that allows for special methods to be used. The object has an attribute that stores variables names needed for some functions, including age, sex, births, deaths and population.

Usage

vital(
  ...,
  key = NULL,
  index,
  .age = NULL,
  .sex = NULL,
  .deaths = NULL,
  .births = NULL,
  .population = NULL,
  regular = TRUE,
  .drop = TRUE
)

Arguments

...

A set of name-value pairs

key

Variable(s) that uniquely determine time indices. NULL for empty key, and c() for multiple variables. It works with tidy selector (e.g. tidyselect::starts_with())

index

A variable to specify the time index variable.

.age

Character string with name of age variable

.sex

Character string with name of sex variable

.deaths

Character string with name of deaths variable

.births

Character string with name of births variable

.population

Character string with name of population variable

regular

Regular time interval (TRUE) or irregular (FALSE). The interval is determined by the greatest common divisor of index column, if TRUE.

.drop

If TRUE, empty key groups are dropped.

Value

A tsibble with class vital.

Author(s)

Rob J Hyndman

See Also

tsibble::tsibble()

Examples

# create a vital with only age as a key
vital(
  year = rep(2010:2015, 100),
  age = rep(0:99, each = 6),
  mx = runif(600, 0, 1),
  index = year,
  key = age,
  .age = "age"
)

[Package vital version 1.1.0 Index]