| attachSubtotals {dembase} | R Documentation |
Attach a subtotal or set of subtotals to an object of class
Counts with missing values.
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())
object |
Object of class |
subtotals |
Object of class |
concordances |
A named list of
|
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.
Object of class CountsWithSubtotals.
## '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))