From 6bfef7e19a7b28e9d27e26952e23559a0b695da2 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:08:30 +0000 Subject: [PATCH] Warn if node labels mismatched --- R/write.tree.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/write.tree.R b/R/write.tree.R index 61c9bdd..9312f34 100644 --- a/R/write.tree.R +++ b/R/write.tree.R @@ -69,7 +69,12 @@ write.tree <- brl <- !is.null(phy$edge.length) nodelab <- !is.null(phy$node.label) if (check_tips) phy$tip.label <- checkLabel(phy$tip.label) - if (nodelab) phy$node.label <- checkLabel(phy$node.label) + if (nodelab) { + if (length(phy[["node.label"]]) != phy[["Nnode"]]) { + warning("Length of node.label does not match number of nodes.") + } + phy$node.label <- checkLabel(phy$node.label) + } f.d <- paste0(":%.", digits, "g") n <- length(phy$tip.label)