rotateAgeTime: Rotate the age-time plan used by a demographic array

Description Usage Arguments Details Value See Also Examples

Description

Convert a DemographicArray between age-time, age-chort, and time-cohort formats.

Usage

1
2
3
4
rotateAgeTime(object, to = NULL, name = NULL)

## S4 method for signature 'DemographicArray'
rotateAgeTime(object, to = NULL, name = NULL)

Arguments

object

An object of class DemographicArray.

to

The dimtypes of object after the age-time plan has been rotated.

name

The name of the new age, time, or cohort dimension.

Details

If the array has dimensions with two out of the three dimtypes "age", "time", "cohort", then replace one of these dimensions with a new dimension with the missing dimtype, and rearrange the array accordingly. If, for instance, an array has dimensions with dimtypes "age" and "time", then replace either the age or time dimension with a cohort dimension, and rearrange cells within the array accordingly.

object must have a regular age-time plan (see hasRegularAgeTime. Negative ages are not allowed, and cohorts must not start later than the last time point or period. object must also not contain any "open" age intervals, time intervals, or cohorts - ie intervals that include positive or negative infinity.

The argument to gives the dimensions used in the new age-time plan. It can be one of "age-time", "time-age", "age-cohort", "cohort-age", "time-chort", or "cohort-time". The abbreviations "at", "ta", "ac", "ca", "tc", or "ct" can also be used. (For production code, however, the full versions are better, since they are more self-documenting.) to is not case-sensitive, and only enough characters to uniquely identify the option need to be supplied.

By default the new dimension is named after the corresponding dimtype: for instance, if the new dimension has dimtype "cohort", then the new dimension is named "cohort". However, an alternative name can be provided via the name argument.

Value

An object with the same class as object.

See Also

dimtypes

Examples

1
2
3
4
5
x <- Counts(array(1:6,
                  dim = c(3, 2),
                  dimnames = list(age = c("0-4", "5-9", "10-14"),
                                  time = c(2000, 2005))))
rotateAgeTime(x, to = "age-cohort")

StatisticsNZ/dembase documentation built on Dec. 25, 2021, 4:49 p.m.