Functions for getting or changing the ID labels of pedigree members.
Usage
relabel(
x,
new = "asPlot",
old = labels(x),
reorder = FALSE,
returnLabs = FALSE,
.alignment = NULL
)
# S3 method for ped
labels(object, ...)
# S3 method for list
labels(object, ..., unlist = TRUE)
Value
labels() returns a character vector containing the ID labels of all
pedigree members. If the input is a list of ped objects, the output is a list
of character vectors.
relabel() by default returns a ped object similar to x, but with
modified labels. If returnLabs is TRUE, the new labels are returned as a
named character vector
Arguments
x
A ped object or a list of such.
new
The following values are valid (see Details and Examples):
a character vector containing new labels. If named, interpreted as
old = new
a function, which should take the old labels as input and output a
character of the same length
one of the special keywords "asPlot" (default) or "generations"
old
A vector of ID labels, of the same length as new. (Ignored if
new is one of the special words.) If not given, taken from the names of
new if these exist.
reorder
A logical. If TRUE, reorderPed() is called on x after
relabelling. Default: FALSE.
returnLabs
A logical. If TRUE, the new labels are returned as a named
character vector.
.alignment
A list of alignment details for x, used if new equals
"asPlot" or "generations". If not supplied, this is computed internally
with .pedAlignment().
object
A ped object.
...
Not used.
unlist
A logical; if TRUE (default), the output is unlisted to a
single character vector.
Details
By default, relabel(x) relabels everyone as 1, 2, ..., in the order given
by the plot (top to bottom; left to right).
Alternatively, relabel(x, "generations") labels the members in the top
generation I-1, I-2, ..., in the second generation II-1, II-2, ..., etc.
x = nuclearPed()
x
labels(x)
y = relabel(x, new = "girl", old = 3)
y
# Back to the numeric labelsz = relabel(y)
stopifnot(identical(x,z))
# Generation labelsrelabel(x, "generations")