dimtypes {dembase} | R Documentation

## Get or set the dimtypes of an object.

### Description

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

### Usage

    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"`

- `"state"`. The default dimtype, used for any attribute that is not dealt with by the more specialized dimtypes.

- `"age"`. Age, measured on a numerical scale Can be 'exact' ages, or age-groups. If age is measured qualitatively (eg `"children"` and `"adults"`), then dimtype `"state"` should be used instead. An object can have at most one dimension with dimtype `"age"`.

- `"sex"`. Biological sex.

- `"time"`. Time, measured on a numerical scale. Can be points in time, or intervals between points in time. If time is measured qualitatively (eg `"before"` and `"after"`), then dimtype `"state"` should be used instead.

- `"origin"`, `"destination"`. Starting and finishing values for an attribute that is subject to change, such as country of residence. `"origin"` and `"destination"` dimensions must come in pairs with a common base name and suffixes `"_orig"` and `"_dest"`, each `"country_orig"` and `"country_dest"`. There is no limit to the number of origin-destination pairs that an object may have.

- `"parent"`, `"child"`. Parents' attributes versus those of their children. Used to model transmission of attributes such as ethnicity from parents to children. `"parent"` and `"child"` dimensions must come in pairs with a common base name and suffixes `"_parent"` and `"_child"`, e.g. `"ethnicity_parent"` and `"ethnicity_child"`. There is no limit to the number of parent-child pairs that an object may have.

- `"iteration"`. Iteration number from a simulation. An object can have at most one dimension with dimtype `"iteration"`. If an object has a dimension with dimtype `"iteration"` it may not have a dimension with dimtype `"quantile"`.

- `"quantile"`. Sample quantiles, typically summarizing simulation results. An object can have at most one dimension with dimtype `"quantile"`. If an object has a dimension with dimtype `"quantile"` it may not have a dimension with dimtype `"iteration"`.

- `"triangle"`. Lexis 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

    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)

[Package dembase version 0.0.0.119 Index]