read.newick: Newick or Nexus style tree reader

View source: R/read.newick.R

read.newickR Documentation

Newick or Nexus style tree reader


The function read.newick reads a simple Newick style tree from file.

The function readNexus reads a Nexus formatted tree, optionally with bootstrap values as node labels.


read.newick(file="", text, ...)
readNexus(file="", format=c("standard","raxml"))



name of text file with single Newick style tree or multiple trees, one per line. For readNexus this should be a Nexus format tree.


character string containing tree.


file format (source) for readNexus. In the case of format="standard", from ape will be used internally. For format="raxml", the parser assumes that bootstrap values have been stored as node labels in the format [&label=bootstrap].


optional arguments to be passed to scan. Note that if the arguments sep or what are supplied this could generate an error. Useful optional arguments might include skip (number of lines to skip) and nlines (number of lines to read).


The function read.newick is almost completely redundant with read.tree. At the time of development, it was more 'robust' than read.tree in that it didn't fail if the tree contained so-called 'singles' (nodes with only one descendant); however, read.tree can now handle singleton nodes without difficulty.

The function readNexus can read a Nexus formatted tree from file (like; however, it can also parse the node labels as bootstrap values. This is the output format from the software RAxML. For Nexus tree files with complex node labels (e.g., from the software MrBayes) it will probably fail to parse node labels correctly, if at all.


An object of class "phylo", possibly containing singles (see; or an object of class "multiPhylo".


Liam Revell


Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223.

See Also




phytools documentation built on Sept. 2, 2022, 1:06 a.m.