pairAligned: Test whether pairs of dimensions aligned.

Description Usage Arguments Details Value See Also Examples

Description

Dimensions with dimtypes "origin" and "destination" or "parent" and "child" come in pairs. pairAligned tests whether the members of each pair have the same categories, in the same order. If they do, pairAligned returns TRUE. If not, it raises an error with a message that describes the differences.

Usage

1
2
3
4
5
6
7
pairAligned(object, base = NULL)

## S4 method for signature 'DemographicArray'
pairAligned(object, base = NULL)

## S4 method for signature 'MetaData'
pairAligned(object, base = NULL)

Arguments

object

An object of class DemographicArray.

base

Character vector giving the "base names" for the dimension pairs. If base is omitted, the base names from all dimensions with dimtype "origin", "destination", "parent", or "child" are used.

Details

By default pairAligned tests all origin-destination and parent-child pairs. Argument base can be used to restrict the test to specific pairs. See below for an example.

Value

TRUE or an error describing any differences.

See Also

Pairs of dimensions can be aligned using function alignPair. In programming, functions try and tryCatch may be useful for intercepting and dealing with errors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
x <- Counts(array(1:4,
                  dim = c(2, 2),
                  dimnames = list(reg_orig = c("A", "B"),
                                  reg_dest = c("A", "B"))))
pairAligned(x)
x <- Counts(array(1:6,
                  dim = 3:2,
                  dimnames = list(reg_orig = c("A", "B", "C"),
                                  reg_dest = c("A", "B"))))
## Not run: pairAligned(x)

## first pair not aligned; second pair OK
x <- Counts(array(1:16,
                  dim = c(2, 2, 2, 2),
                  dimnames = list(reg_orig = c("B", "A"),
                                  reg_dest = c("A", "B"),
                                  income_parent = c("Low", "High"),
                                  income_child = c("Low", "High"))))
## Not run: pairAligned(x)
pairAligned(x, base = "income")
## Not run: pairAligned(x, base = "reg")

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