attachSubtotals: Attach a set of known subtotals to a Counts object.

Description Usage Arguments Details Value See Also Examples

Description

Attach a subtotal or set of subtotals to an object of class Counts with missing values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
attachSubtotals(object, subtotals, concordances = list())

## S4 method for signature 'Counts,Counts'
attachSubtotals(object, subtotals, concordances = list())

## S4 method for signature 'Counts,Values'
attachSubtotals(object, subtotals, concordances = list())

## S4 method for signature 'Counts,numeric'
attachSubtotals(object, subtotals, concordances = list())

Arguments

object

Object of class Counts, with missing values. All non-missing values must be non-negative integers.

subtotals

Object of class Counts, or a single number. Missing values are not permitted. All values must be non-negative integers.

concordances

A named list of ManyToOne concordances.

Details

All values in subtotals and all non-missing values in object must be non-negative integers.

Neither object nor subtotals may have dimtype "iteration" or "quantile".

Concordances supplied through the concordances argument are used to map values from object on to subtotals. The concordances are supplied as a named list, with the names specifying which dimension of object each concordances should be used with. See below for an example.

Value

Object of class CountsWithSubtotals.

See Also

impute, CountsWithSubtotals

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## 'subtotals' have class "Counts"
popn <- demdata::VAPopn
popn <- Counts(popn)
popn <- extrapolate(popn, along = "age", labels = "45-49", type = "missing")
subtotals <- Counts(array(c(65000, 64000),
                          dim = 1:2,
			  dimnames = list(age = "45-49", sex = c("Male", "Female"))))
attachSubtotals(popn, subtotals = subtotals)

## 'subtotals' single number
attachSubtotals(popn, subtotals = 500000)

## 'concordances' argument
x <- CountsOne(c(1, 4, NA, NA, 7),
               labels = c("a", "b", "c", "d", "e"),
               name = "region")
subtotals <- CountsOne(c(10, 11),
                       labels = c("U", "V"),
                       name = "region")
conc <- data.frame(from = c("a", "b", "c", "d", "e"),
                   to = c("U", "U", "U", "V", "V"))
conc <- Concordance(conc)
attachSubtotals(x,
                subtotals = subtotals,
                concordances = list(region = conc))

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