dimtypes: Get or set the dimtypes of an object.

Description Usage Arguments Details Value Note See Also Examples

Description

Query or (to a limited extent) change the dimtypes of an object.

Usage

1
2
3
4
5
6
7
8
9
dimtypes(object, use.names = TRUE)

dimtypes(object) <- value

## S4 method for signature 'MetaData'
dimtypes(object, use.names = TRUE)

## S4 replacement method for signature 'MetaData'
dimtypes(object) <- value

Arguments

object

Object of class DemographicArray.

use.names

Logical. Whether to include the names of the dimensions in the return value.

value

Character vector of valid dimtypes. See table below for a list of valid dimtypes.

Details

Each dimension of a DemographicArray object has a 'dimtype' describing the type of information held by that dimension. Examples include "age", "time", and "state". See below for details.

Every dimension of a DemographicArray object has a dimtype. A dimtype identifies the type of variable encoded by the dimension.

The table below lists valid dimtypes. The dimtypes from "age" to "destination" are the most commonly-encountered, with the remaining dimtypes being more specialized. Different dimtypes require different dimscales.

dimtype Description Permitted dimscales
"state" Any qualitative attribute "Categories"
"age" Age "Intervals", "Points"
"sex" Sex "Sexes"
"time" Periods or exact times "Intervals", "Points"
"origin", "destination" Starting and finishing states "Categories"
"parent", "child" Parent's state versus child's state "Categories"
"cohort" Cohort "Intervals"
"iteration" Simulation number "Iterations"
"quantile" Quantile (between 0 and 1) "Quantiles"
"triangle" Lexis triangle "Triangle"

Value

dimtypes returns a character vector with the dimtypes of each dimension.

The replacement method changes the dimtypes of object.

Note

Changing the dimtype of a dimension in an existing object can be tricky, since the dimension may have dimscales that are not permitted for the new dimtype. If major changes to the dimtypes and dimscales of an object are required, it may be easiest to create the object again from scratch, perhaps using as.array on the object first.

See Also

dimscales

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(demdata)
x <- Counts(VADeaths2)
dimtypes(x)

a <- array(1:8,
           dim = c(2, 2, 2),
           dimnames = list(age = c("0-39", "40+"),
                           tri = c("Upper", "Lower"),
                           period = c("1961-2000", "2001-2040")))
x <- Counts(a)
dimtypes(x)
dimtypes(x)[2] <- "triangle"
dimtypes(x)

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