componentNames: Get or set the names of components of a demographic account.

Description Usage Arguments Value See Also Examples

Description

A demographic account contains counts of population, plus one or more components such as births, deaths, or internal migration. componentNames extracts the names of the components. setNamesComponents and the replacement form of namesComponents can be used to specify the names.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
componentNames(object)

componentNames(object) <- value

setComponentNames(object, value)

## S4 method for signature 'DemographicAccount'
componentNames(object)

## S4 replacement method for signature 'DemographicAccount'
componentNames(object) <- value

## S4 method for signature 'DemographicAccount'
setComponentNames(object, value)

Arguments

object

An object of class DemographicAccount.

value

Names of the components.

Value

componentNames returns a vector of names. setComponentNames and the replacement form of componentNames return a modified version of object.

See Also

The names can also be set when creating the account using functions Movements and Transitions. Components can be extracted using function components.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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))

componentNames(account)
componentNames(account) <- c("Births", "Deaths") # capitalized
componentNames(account)
library(dplyr) # to get pipes
account <- account %>%
setComponentNames(value = c("BIRTHS", "DEATHS"))
account

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