| resetDiag {dembase} | R Documentation |
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.
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)
object |
An object of class |
base |
Character vector giving the "base names" for the
origin-destination pairs. If |
reset |
The new value to be used on the diagonal. |
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.
The original object, with the objects on the diagonal changed.
collapseOrigDest to collapse away
origin and destination dimensions. alignPair
puts origin and destination categories in the same order.
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)