components {dembase} | R Documentation

## Extract one or more components from a demographic account.

### Description

A `demographic account` contains counts of population, plus one or more components such as births, deaths, or internal migration. `components` can be used to extract one or more of these components, as a named list.

### Usage

    components(object, names = NULL, simplify = FALSE)

    ## S4 method for signature 'DemographicAccount'
    components(object, names = NULL, simplify = TRUE)

### Arguments

`object` | An object of class `DemographicAccount`.
`names` | Names of the components. If omitted all components are returned.
`simplify` | Logical. If `simplify` is `TRUE` (the default), and if only one component is requested, then the return value for `components` is the Counnts object itself, rather than a named list of length 1.

### Value

A single `Counts` object, or a named list of Counts objects.

### See Also

Population counts can be extracted using function `population`.

### Examples

    population <- Counts(array(c(10, 15, 13, 16),
                               dim = c(2, 2),
                               dimnames = list(age = c("0-29", "30+"),
                                               time = c(1970, 2000))))
    births <- Counts(array(13,
                           dim = c(1, 1),
                           dimnames = list(age = "30+",
                                           time = "1971-2000")))
    deaths <- Counts(array(c(0, 9),
                           dim = c(2, 1),
                           dimnames = list(age = c("0-29", "30+"),
                                           time = c("1971-2000"))))
    account <- Movements(population = population,
                         births = births,
                         exits = list(deaths = deaths))

    components(account)
    components(account, names = "births") ## Counts object
    components(account, names = "births", simplify = FALSE) ## named list
    components(account, names = c("deaths", "births"))

[Package dembase version 0.0.0.119 Index]