Update Labels
This function changes labels (names or rownames) giving two vectors (old
and new
). It is a generic function with several methods as described below.
updateLabel(x, old, new, ...) ## S3 method for class 'character' updateLabel(x, old, new, exact = TRUE, ...) ## S3 method for class 'DNAbin' updateLabel(x, old, new, exact = TRUE, ...) ## S3 method for class 'AAbin' updateLabel(x, old, new, exact = TRUE, ...) ## S3 method for class 'phylo' updateLabel(x, old, new, exact = TRUE, nodes = FALSE, ...) ## S3 method for class 'evonet' updateLabel(x, old, new, exact = TRUE, nodes = FALSE, ...) ## S3 method for class 'data.frame' updateLabel(x, old, new, exact = TRUE, ...) ## S3 method for class 'matrix' updateLabel(x, old, new, exact = TRUE, ...)
x |
an object where to change the labels. |
old, new |
two vectors of mode character (must be of the same length). |
exact |
a logical value (see details). |
nodes |
a logical value specifying whether to also update the node labels of the tree or network. |
... |
further arguments passed to and from methods. |
This function can be used to change some of the labels (see examples) or all of them if their ordering is not sure.
If exact = TRUE
(the default), the values in old
are matched exactly with the labels; otherwise (exact = FALSE
), the values in old
are considered as regular expressions and searched in the labels with grep
.
an object of the same class than x
.
Emmanuel Paradis
## Not run: ## the tree by Nyakatura & Bininda-Emonds (2012, BMC Biology) x <- "https://static-content.springer.com/esm/art" y <- "3A10.1186" z <- "2F1741-7007-10-12/MediaObjects/12915_2011_534_MOESM5_ESM.NEX" ## The commande below may not print correctly in HTML because of the ## percentage symbol; see the text or PDF help page. url <- paste(x, y, z, sep = " TC <- read.nexus(url) tr <- TC$carnivoreST_bestEstimate old <- c("Uncia_uncia", "Felis_manul", "Leopardus_jacobitus") new <- c("Panthera_uncia", "Otocolobus_manul", "Leopardus_jacobita") tr.updated <- updateLabel(tr, old, new) ## End(Not run) tr <- rtree(6) ## the order of the labels are randomized by this function old <- paste0("t", 1:6) new <- paste0("x", 1:6) updateLabel(tr, old, new) tr
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.