Skip to contents

Read a tree in a newick format and convert it to a rankedPhylo

Usage

read_newick(x)

Arguments

x

a single character string containing tree in a newick format

Value

object of class "rankedPhylo"

Examples

read_newick("((A:1,B:1):1,C:2);")
#> 
#> Phylogenetic tree with 3 tips and 2 internal nodes.
#> 
#> Tip labels:
#>   A, B, C
#> 
#> Rooted; includes branch lengths.

# Note, not all valid newick trees are valid ranked trees
try( read_newick("((A,B),C);") ) 
#> Error in .is.ultrametric_ape(phy, tol, option, length(phy$tip.label)) : 
#>   the tree has no branch lengths