resetDiag: Reset values where origin equals destination.

Description Usage Arguments Details Value See Also Examples

Description

Given a DemographicArray with dimtypes "origin" and "destination", set cells on the "diagonal", ie where the origin equals the destination, to a value such as 0 or NA.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
resetDiag(object, base = NULL, reset = NULL)

## S4 method for signature 'Counts,ANY,ANY'
resetDiag(object, base = NULL, reset = NULL)

## S4 method for signature 'Counts,ANY,missing'
resetDiag(object, base = NULL, reset = NULL)

## S4 method for signature 'Counts,ANY,'NULL''
resetDiag(object, base = NULL, reset = NULL)

## S4 method for signature 'Values,ANY,ANY'
resetDiag(object, base = NULL, reset = NULL)

## S4 method for signature 'Values,ANY,'NULL''
resetDiag(object, base = NULL, reset = NULL)

## S4 method for signature 'Values,ANY,missing'
resetDiag(object, base = NULL, reset = NULL)

Arguments

object

An object of class DemographicArray.

base

Character vector giving the "base names" for the origin-destination pairs. If base is omitted, the base names from all dimensions with dimtype "origin" and "destination" are used.

reset

The new value to be used on the diagonal.

Details

The origin and destination dimensions are specified via the base argument. base is the "base name", that is, the first part of the dimension name. If is an origin dimension called "region_orig", for instance, and a destination called "region_dest", then the base name is "region". If no base argument is supplied, then all origin and destination dimensions in the object are used.

If no reset argument is supplied, then it defaults to 0 in the case of Counts objects and NA in the case of Values objects.

Value

The original object, with the objects on the diagonal changed.

See Also

collapseOrigDest to collapse away origin and destination dimensions. alignPair puts origin and destination categories in the same order.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x <- Counts(array(1:4,
                  dim = c(2, 2),
                  dimnames = list(reg_orig = c("A", "B"),
                                  reg_dest = c("A", "B"))))
resetDiag(x)
resetDiag(x, base = "reg")
resetDiag(x, reset = NA)

## with Values object, reset defaults to NA, not 0
x.val <- as(x, "Values")
resetDiag(x.val)

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