relabel_with_names: Change labels from glottocodes to names

View source: R/labels.R

relabel_with_namesR Documentation

Change labels from glottocodes to names

Description

Looks up glottolog language names corresponding to glottocodes and replaces tip and node labels, which contain glottocodes, with the appropriate names.

Usage

relabel_with_names(phy, glottolog_version)

Arguments

phy

A phylo object, the tree to manipulate.

glottolog_version

A character string, specifying which glottolog version to use. Currently available options are '4.0' through to '4.8' and '5.0'. If no value is specified then the newest available version is used.

Details

Also recognizes and retains duplicate suffixes, i.e., a hyphen followed by one or more numerals at the end of the string (see apply_duplicate_suffixes).

Labels without glottocodes are left unchanged and a warning is given. The version of glottolog to use for look-up can be controlled with glottolog_version.

Value

A phylo object, the manipulated tree.

Examples


library(ape)

# Replace full glottolog labels with names
tree <- get_glottolog_trees("Kresh-Aja")
plot(tree)
nodelabels(tree$node.label)
tree2 <- relabel_with_names(tree)
plot(tree2)
nodelabels(tree2$node.label)

# Replace abridged labels with names
tree3 <- abridge_labels(tree)
plot(tree3)
nodelabels(tree3$node.label)
tree4 <- relabel_with_names(tree3)
plot(tree4)
nodelabels(tree4$node.label)

# Use names from earlier glottolog version:
tree5 <- relabel_with_names(tree, glottolog_version = "4.3")
plot(tree5)
nodelabels(tree5$node.label)

erichround/glottoTrees documentation built on April 17, 2025, 10:47 a.m.